Mount a dataset, OSS, NAS, or CPFS

更新时间:
复制 MD 格式

DSW instances in public and dedicated resource groups have limited default storage, and the data is not permanent. To expand storage, enable persistent storage, or share data, you can mount a dataset or a storage path to the instance.

Important
  • Data on the cloud disk is cleared if you delete the instance or if it remains stopped for more than 15 days.

  • Data on the system disk is cleared after the instance is stopped or deleted.

Dataset mounting vs. direct storage path mounting

If you need long-term storage or team collaboration, mount a dataset. If you only need storage for temporary tasks or quick expansion, mount a storage path directly.

Feature

Mount a dataset

Mount a storage path directly

Supported cloud services

OSS, NAS, and CPFS

Version management

Supports version management and data acceleration.

Does not support version management.

Data sharing

Supports sharing across multiple instances.

Limited to the current instance.

Operational complexity

Requires creating and configuring a dataset.

Requires only mounting the storage path directly.

Use cases

Long-term storage, team collaboration, and high-security requirements.

Temporary tasks and rapid storage expansion needs.

Startup mounting vs. dynamic mounting

Two mounting methods are available: startup mounting and dynamic mounting.

  • Startup mounting: Configured when you create or change the settings of an instance. This action requires an instance restart to take effect.

  • Dynamic mounting: Uses the PAI SDK in a running instance and does not require a restart.

Limitations

  • Unique path: The mount path for each dataset must be unique.

  • Write limit: Avoid frequent write operations in OSS mount directories. This can cause performance degradation or failed operations.

  • Git limit: Git operations are not supported in OSS mount directories. Run Git commands in local directories or other non-mounted paths.

Dynamic mounting limitations

  • Read-only limit: Dynamic mounting supports only read-only access and does not support write operations. It is suitable for scenarios that require fast mounting or temporary read-only access.

  • Storage type limit: Dynamic mounting supports only OSS and NAS.

  • Resource limit: Dynamic mounting does not currently support Lingjun resources.

Startup mounting

To mount at startup, use the Dataset Mounting or Mount storage options on the instance configuration page. You must restart the instance for the changes to take effect.

Mount a dataset

  1. Create a dataset

    Log on to the PAI console. In the navigation pane on the left, choose AI Asset Management > Dataset. On the page that appears, create a custom dataset or a public dataset. For more information, see Create and manage datasets.

  2. Mount the dataset

    On the DSW instance configuration page, find the Dataset Mounting parameter. You can access this page when creating an instance or by clicking Change Settings on an existing one. Click Custom, then select the created dataset and enter a Mount Path.

Note

Notes on mounting a custom dataset:

  • CPFS dataset: When you configure a CPFS dataset, the VPC of the DSW instance must be the same as that of the CPFS file system. Otherwise, instance creation will fail.

  • NAS dataset: When you configure a NAS dataset, configure the network and select a security group.

  • Using a dedicated resource group: When you use a dedicated resource group, the first dataset must be a NAS dataset. This dataset is mounted to both your specified path and the default DSW working directory at /home/admin/workspace.

Mount a storage path directly

This section uses mounting an OSS storage path as an example.

  1. Create an OSS bucket

    Activate OSS and create a bucket.

    Important

    The bucket's region must be the same as the PAI region. A bucket's region cannot be changed after the bucket is created.

  2. Mount the OSS path

    On the DSW instance configuration page (opened when creating an instance or by clicking Change Settings for an existing instance), find the Mount storage parameter. Click OSS, select the created OSS bucket path, and enter a Mount Path. The Advanced Configurations field is empty by default. You can configure it as needed. For more information, see Advanced mount configuration.

Dynamic mounting

Dynamic mounting lets you mount a dataset or storage path by using the PAI SDK within a running DSW instance. A restart is not required.

Prerequisites

  1. Install the PAI Python SDK. In the DSW instance Terminal, run the following command. Python 3.8 or later is required.

    python -m pip install pai>=0.4.11
  2. Configure access credentials for the SDK to access PAI.

    • Method 1: Configure the DSW instance to use the default PAI role or a custom RAM role. Open the instance configuration page, click Show More at the bottom, and select an instance RAM role. For more information, see Configure a RAM role for a DSW instance.

    • Method 2: Manually configure by using the command-line tool provided by the PAI Python SDK. In the Terminal, run the following command to configure access parameters. For an example, see Initialization.

      python -m pai.toolkit.config

Examples

  • Mount to the default path

    The data is mounted to the default mount path within the instance. For official pre-built instance images, the default path is /mnt/dynamic/.

    from pai.dsw import mount
    # Mount an OSS path.
    mount_point = mount("oss://<YourBucketName>/Path/Data/Directory/") 
    # Mount a dataset. The input parameter is the dataset ID.
    # mount_point = mount("d-m7rsmu350********")
  • Mount to a specified path

    Dynamic mounting requires mounting data to a specific path (or a subdirectory) inside the container. You can get the dynamic mount path by using the API provided by the SDK.

    from pai.dsw import mount, default_dynamic_mount_path
    # Get the default mount path of the instance.
    default_path = default_dynamic_mount_path()
    mount_point = mount("oss://<YourBucketName>/Path/Data/Directory"
                  , mount_point=default_path + "tmp/output/model")
  • Dynamically mount NAS

    from pai.dsw import mount, default_dynamic_mount_path
    # Get the default mount path of the instance.
    default_path = default_dynamic_mount_path()
    # Mount NAS. The NAS endpoint and the instance must be in the same VPC. Replace <region> with the region ID, such as cn-hangzhou.
    mount("nas://06ba748***-xxx.<region>.nas.aliyuncs.com/", default_path+"mynas3/")
  • View all mount configurations in the instance

    from pai.dsw import list_dataset_configs
    print(list_dataset_configs())
  • Unmount data

    from pai.dsw import mount, unmount
    mount_point = mount("oss://<YourBucketName>/Path/Data/Directory/")
    # The input parameter is the mount path, which is the MountPath value returned by list_dataset_configs.
    # After running the unmount command, it takes a few seconds for the change to take effect.
    unmount(mount_point)

Advanced mount configuration

When you configure a mount, you can also set advanced parameters to adapt to different scenarios, such as fast reads/writes, incremental writes, and read-only access, to optimize performance.

Advanced mount configuration

OSS mounting

For an OSS mount, you can use advanced configurations to specify Jindo-related settings or use ossfs for mounting.

  • In advanced configuration, set {"mountType":"ossfs"} to use ossfs for mounting OSS storage. If this parameter is not set, Jindo is used by default.

  • In advanced configuration, set the Jindo parameters to use the Jindo mount more flexibly. Common scenarios are as follows:

    • Fast read and write: Allows reads and writes with high read speeds, but concurrent operations may cause data inconsistency. This is suitable for mounting training data and models, but not for working directories.

      {
        "fs.oss.download.thread.concurrency": "2 × number of CPU cores",
        "fs.oss.upload.thread.concurrency": "2 × number of CPU cores",
        "fs.jindo.args": "-oattr_timeout=3 -oentry_timeout=0 -onegative_timeout=0 -oauto_cache -ono_symlink"
      }
    • Incremental writes: Ensures data consistency during incremental writes, but overwriting existing data may cause consistency issues. The read speed is slightly slower. This is suitable for saving trained model weight files.

      {
        "fs.oss.upload.thread.concurrency": "2 × number of CPU cores",
        "fs.jindo.args": "-oattr_timeout=3 -oentry_timeout=0 -onegative_timeout=0 -oauto_cache -ono_symlink"
      }
    • Consistent read and write: Maintains data consistency during concurrent read and write operations. This is suitable for scenarios with high data consistency requirements that can tolerate slower read speeds. It is ideal for storing code projects.

      {
        "fs.jindo.args": "-oattr_timeout=0 -oentry_timeout=0 -onegative_timeout=0 -oauto_cache -ono_symlink"
      }
    • Read-only: Allows only read operations and prevents writes. This is suitable for mounting public datasets.

      {
        "fs.oss.download.thread.concurrency": "2 × number of CPU cores",
        "fs.jindo.args": "-oro -oattr_timeout=7200 -oentry_timeout=7200 -onegative_timeout=7200 -okernel_cache -ono_symlink"
      }

General-purpose NAS and CPFS

For General-purpose NAS and CPFS mounts, you can use advanced configurations to improve storage throughput for the container.

In the advanced configuration, set the nconnect parameter. For example, {"nconnect":"<example_value>"}. Replace <example_value> with a positive integer.

View mount configurations

Open the DSW instance and, in the Terminal, run the following commands to verify whether the NAS and OSS datasets are successfully mounted.

# View all mounts
mount
# Query NAS mount paths
mount | grep nas
# Query OSS mount paths
mount | grep oss

An output similar to the following indicates that the dataset is successfully mounted.

(base) /mnt/workspace> mount | grep nas
xxx /dsw01/ on /mnt/workspace type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,noresvport,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=xxx,mountvers=3,mountport=2049,mountproto=tcp,local_lock=all,addr=xxx)
xxx /dsw01/ on /mnt/data_nas type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,noresvport,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=xxx,mountvers=3,mountport=2049,mountproto=tcp,local_lock=all,addr=xxx)
xxx:/dsw01/ on /home/admin/workspace type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,noresvport,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=xxx,mountvers=3,mountport=2049,mountproto=tcp,local_lock=all,addr=xxx)
(base) /mnt/workspace>
(base) /mnt/workspace> mount | grep oss
jindo-fuse on /mnt/data_oss type fuse.jindo-fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
(base) /mnt/workspace>
  • The NAS dataset is mounted to the /mnt/data_nas, /mnt/workspace, and /home/admin/workspace directories. Among them, /mnt/data_nas is the mount path specified when you created the DSW instance, and the other two paths are the default DSW working directories to which the first NAS dataset is mounted. As long as your NAS volume and service run normally, your data and code are stored persistently.

  • The OSS dataset is mounted to the /mnt/data_oss directory in the DSW instance.

FAQ

Q: Mounted OSS files not visible in JupyterLab

This is because the DSW file browser shows the instance's working directory by default, which is typically /mnt/workspace. The mount path you specified for OSS (for example, /mnt/data) is not under the default working directory, so it does not appear in the file browser.

Solutions:

  • Access through code: Your files have actually been mounted successfully. In your code, you need to use the full mount path to access them, such as open('/mnt/data/my_file.csv').

  • Change the mount point: To see the files easily in the UI, you can set the mount path to a subdirectory under the working directory when you configure the mount, such as /mnt/workspace/my_oss_data. After the mount is complete, you can see your OSS files in the my_oss_data folder in the file browser.

  • Access through the Terminal: In the DSW Terminal, you can use the cd /mnt/data command to navigate to the mount directory, and then use commands like ls to view and manage files.

Q: How to resolve OSS mount connection errors?

This error indicates the mount connection between the DSW instance and OSS is lost. Possible causes and solutions are as follows:

  1. RAM role permission issue: Check if the RAM role configured for your DSW instance has been granted permission to access OSS (for example, AliyunPAIDLCAccessingOSSRole). Insufficient permissions are a common cause of failure to read from OSS.

  2. Insufficient resources for the mount service: During high-intensity random read/write or large-scale small file operations, the ossfs or JindoFuse process responsible for the mount may crash due to an out-of-memory (OOM) error. In the Advanced Configurations of the mount settings, you can disable the metadata cache or increase the memory configuration. For more information, see JindoFuse.

  3. Restore the connection:

    • For startup mounting, the easiest way to restore the connection is to restart the DSW instance. The system will automatically re-establish the mount.

    • You can also run a dynamic mounting command using the PAI SDK to remount the path without restarting the instance.

Q: What data types are supported for mounting?

DSW supports using cloud storage services like OSS, NAS, and CPFS by creating a dataset or directly mounting a storage path. 

  • Alibaba Cloud Drive is not supported: DSW does not currently support directly mounting a personal Alibaba Cloud Drive. It is recommended to store data that needs processing in OSS.

  • Mounting MaxCompute tables is not supported: Table data from MaxCompute (formerly ODPS) cannot be "mounted" to a DSW directory like a file system. You can read and write this data in your DSW code by using the SDK or API provided by PAI. For more information, see Use PyODPS to read and write MaxCompute tables.

Q: How to ensure data persistence and migration?

The system disk of a DSW instance provides temporary storage. For a public resource group, data is cleared if the instance is stopped for more than 15 days. For a dedicated resource group, data on the system disk is cleared as soon as the instance is stopped or deleted.

To store data and code persistently or to migrate them between instances, you must use external storage. 

  • Persistence solution: Save all your important data, code, and models to a mounted OSS or NAS path. This way, even if the DSW instance is deleted, all your assets remain safely stored in your own OSS or NAS.

  • Migration solution: When you need to migrate data from one DSW instance to another, simply mount the same OSS or NAS path to the new instance. This is the most convenient data migration method.

Q: Exporting data from a failed DSW instance

If a DSW instance cannot start due to insufficient resources or other reasons, the data on its system disk is not immediately lost. You can try the following methods to export the data:

  1. Change the instance specification and restart: On the instance list page, click "Change Settings", select another available instance specification, and then restart the instance. Changing specifications does not cause data loss on the system disk. Once the instance starts successfully, immediately back up your data to OSS or NAS.

  2. Switch the region or availability zone: If the current region has insufficient resources and your data is already stored in external storage, you can try creating a new instance and mounting the same OSS/NAS storage to recover the data.

  3. Contact technical support: If the methods above do not resolve the issue, submit a ticket to technical support for assistance.

Important

If you receive a notification that "The system disk will be released in X days," you must start the instance by changing specifications or other means to back up your data before the deadline.

Related documentation

For more frequently asked questions, see DSW FAQ