- Documentation
Torch Object Storage
Best Practices
Accessing and storing TOS data in PyTorch jobs
Best Practices
Accessing and storing TOS data in PyTorch jobs
Accessing and storing TOS data in PyTorch jobs
This topic explains how to access and store TOS data in PyTorch jobs.
- Make sure you have activated TOS and created a TOS bucket. For instructions, see Quick start.
- Your operating system is Linux x86-64.
- You have installed Python 3.8 or a later version.
warning
Versions 3.12 and higher are not recommended, as they are not supported by PyTorch.
Before connecting to TOS, install PyTorch in a Python 3.8+ environment. For more information, see Pytorch. Use the example below to verify that PyTorch was installed successfully.
The steps for different integration methods are as follows.
fsspec
FSX
S3 Connector
tosutil
- Run this command to install tosfs.
- Run this command to initialize the client.
- Run this code to construct an iterable-style dataset.
tip
In this example, we use the bucketname bucket in the Beijing region. Modify the code according to your workloads.
- Run this code to save or load the checkpoint.
tip
In this example, we use the bucketname bucket in the Beijing region. Modify the code according to your workloads.
This section uses veLinux to show how to install FSX and mount a bucket via FSX. For more information on environments and parameters, see the following documents:
- For operating system-specific installation packages, submit a ticket to contact the technical team for the latest builds.
- Run this command to install the client.
- Run this command to check the client version.
- The following version information indicates a successful installation.
- Configure the necessary permissions.
- To mount a bucket, the relevant IAM user must have ListBucket and HeadBucket permissions. To read objects within the mounted bucket, the user needs GetObject permission. To write objects, PutObject and AbortMultipartUpload permissions are required.
- The example below shows a minimal set of permissions. For more information, see Permissions.
- Type this command into your Linux terminal to create a mount point.
- Run this command to mount the bucket.
- Run this command to verify that the mount was successful.
- If successful, the command returns output containing the mount point and bucket name.
- Run this code to construct an iterable-style dataset.
tip
In this example, we use the shard-data/ directory. Modify the code according to your workloads.
- Run this code to save or load the checkpoint.
tip
In this example, we use the checkpoint/ directory. Modify the code according to your workloads.
- Run this command to install the s3 connector base library.
- (Optional) Run this command to install the s3 connector for lighting.
- Configure the environment.
- Run this command to edit the credentials configuration file.
- Run this command to provide your credentials.
- Run this command to save the configurations.
- Run this code to construct an iterable-style dataset.
tip
In this example, we use the shard-data/ directory of the bucketname bucket in the Beijing region. Modify the code according to your workloads.
- Run this code to construct a map-style dataset.
tip
In this example, we use the shard-data/ directory of the bucketname bucket in the Beijing region. Modify the code according to your workloads.
- Run this code to save or load the checkpoint.
tip
In this example, we use the checkpoint/ directory of the bucketname bucket in the Beijing region. Modify the code according to your workloads.
This section uses tosutil to show how to mount a bucket using Filesystem in Userspace (FUSE). However, you can select any alternative tool that best fits your needs.
- Configure tosutil and check its version and connectivity. For instructions, see Quick start.
- This section demonstrates how to mount the bucketname bucket to the ./root directory.
- Run this command to verify that the mount was successful.
- Run this code to construct an iterable-style dataset.
tip
In this example, we use the shard-data/ directory. Modify the code according to your workloads.
- Run this code to save or load the checkpoint.
tip
In this example, we use the checkpoint/ directory. Modify the code according to your workloads.
Last updated: 2026.08.25 10:39:45