Mount a dataset, OSS, NAS, or CPFS
DSW instances in public and dedicated resource groups have limited default storage, and data is cleared after a period of time. By mounting a dataset or storage path, you can expand the storage space of a DSW instance, persist data, and share data across instances.
For DSW instances in a public resource group, data is stored on a free cloud disk with limited space (100 GiB). The data on the cloud disk is cleared when you delete the instance or when the instance is stopped for more than 15 days.
For DSW instances in a dedicated resource group, data is stored on the system disk of the instance. The temporary storage is cleared after the instance is stopped or deleted.
Differences between mounting a dataset and mounting a storage path directly
If you need long-term storage or team collaboration, mount a dataset. If you only need storage for temporary tasks or quick storage 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. |
Mount the path directly. |
|
Use cases |
Long-term storage, team collaboration, and high security requirements. |
Temporary tasks and quick storage expansion. |
Differences between startup mounting and dynamic mounting
DSW supports two mounting methods: startup mounting and dynamic mounting.
Startup mounting: Configure it when you create an instance or change its settings. You must restart the instance for the configuration to take effect.
Dynamic mounting: Mount data in a running instance by using the PAI SDK. You do not need to restart the instance.
Limitations
Unique path: The mount path of each dataset must be unique.
Write limit: Avoid frequent write operations in OSS mount directories. Frequent writes can degrade performance or cause operations to fail.
Git limit: OSS mount directories do not support Git operations. Run Git commands in local directories or other paths that are not mounted.
Dynamic mounting limitations
Read-only: Dynamic mounting supports only read-only access. It is suitable for quick mounting or temporary read-only access.
Storage types: Dynamic mounting supports only OSS and NAS.
Resources: Dynamic mounting does not support Lingjun intelligent computing resources.
Startup mounting
With startup mounting, you set the Dataset Mounting or Storage Mount parameter on the instance configuration page to mount a dataset or storage path. You must restart the instance for the configuration to take effect.
Mount a dataset
-
Create a dataset
Log on to the PAI console. On the AI Asset Management > Dataset page, create a custom dataset or a public dataset. For more information, see Create and manage datasets.
-
Mount the dataset
On the configuration page that appears when you create a DSW instance (for an existing instance, click Change Settings to open the configuration page), find the Dataset Mounting parameter, click Custom, select the dataset that you created, and enter the Mount Path.
Notes on mounting a custom dataset:
CPFS dataset: When you configure a CPFS dataset, the virtual private cloud (VPC) of the DSW instance must be the same as that of the CPFS file system. Otherwise, the instance fails to be created.
NAS dataset: When you configure a NAS dataset, configure the network and select a security group.
Dedicated resource group: If 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
/home/admin/workspace.
Mount a storage path directly
The following example shows how to mount an OSS storage path.
-
Create an OSS bucket
OSS is activated and Create a bucket.
ImportantThe bucket must be in the same region as PAI. After a bucket is created, you cannot change its region.
-
Mount the OSS path
On the configuration page that appears when you create a DSW instance (for an existing instance, click Change Settings to open the configuration page), find the Storage Mount parameter. Click OSS, select the path of the OSS bucket that you created, and enter the Mount Path. The Advanced Configurations field is empty by default. You can configure it as needed by referring to Advanced mount configuration.
Dynamic mounting
With dynamic mounting, you mount a dataset or storage path by using the PAI SDK in a DSW instance. You do not need to restart the instance.
Note: Dynamic mounting supports only read-only access. It supports only OSS and NAS and does not support Lingjun resources.
Prerequisites
-
In the Terminal of the DSW instance, run the following command to install the PAI Python SDK. Python 3.8 or later is required.
python -m pip install pai>=0.4.11 -
Configure the credentials that the SDK uses 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 of the page, and select an instance RAM role. For more information, see Configure a RAM role for a DSW instance.
-
Method 2: Manually configure access by using the command-line tool provided by the PAI Python SDK. In the Terminal, run the following command to configure the access parameters. For an example, see Configuration.
python -m pai.toolkit.config
Examples
The following examples show how to use dynamic mounting without restarting the DSW instance:
-
Mount to the default path
The data is mounted to the default mount path in the instance. For official pre-built 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 you to mount data to a specified path (or subpath) in the container. You can obtain 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, for example, 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 returned by list_dataset_configs. # After you run the unmount command, the change takes a few seconds to take effect. unmount(mount_point)
Advanced mount configuration
When you configure a mount, you can set advanced parameters for scenarios such as fast read and write, incremental writes, and read-only access. These parameters optimize read and write performance.
View mount configurations
Open the DSW instance. In the Terminal, run the following command to check whether NAS and OSS datasets are mounted.
# View all mounts
mount
# Query the NAS mount path
mount | grep nas
# Query the OSS mount path
mount | grep oss
If the system returns the following output, the dataset is 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. /mnt/data_nas is the mount path that you specified when you created the DSW instance. The latter two paths are the default DSW working directories to which the first NAS dataset was mounted. As long as the NAS and the service are running normally, your data and code are persistently stored.
The OSS dataset is mounted to the /mnt/data_oss directory of the DSW instance.
FAQ
Q: Why can't I see a successfully mounted OSS path in the file browser on the left of the JupyterLab interface?
The DSW file browser displays the working directory of the instance by default, which is usually /mnt/workspace. If the mount path that you specify when mounting OSS (for example, /mnt/data) is not in the default working directory, the mounted files are not displayed in the file list on the left.
Solution:
Access files by using code: The files are mounted successfully. In your code, access them by using the full mount path, for example,
open('/mnt/data/my_file.csv').Change the mount point: To view the files in the UI, set the mount path to a subdirectory of the working directory when you configure the mount, for example,
/mnt/workspace/my_oss_data. After mounting is complete, the OSS files are displayed in themy_oss_datafolder in the file browser.Access files by using the Terminal: In the DSW Terminal, run
cd /mnt/datato go to the mount directory, and then use commands such aslsto view and manage files.
Q: Why does my program report "Transport endpoint is not connected" or "Input/output error" when I use a mounted OSS path?
This error indicates that the mount connection between the DSW instance and OSS is disconnected. Possible causes and troubleshooting methods are as follows:
RAM role permissions: Check whether the RAM role configured for the DSW instance is granted the permissions to access OSS (for example,
AliyunPAIDLCAccessingOSSRole). Insufficient permissions are a common cause of OSS read failures.Insufficient mount service resources: During intensive random read and write operations or operations on a large number of small files, the
ossfsorJindoFuseprocess that handles the mount may crash due to insufficient memory (OOM). You can disable the metadata cache in advanced configuration of the mount settings or increase the memory configuration. In advanced configuration, add{"fs.jindo.fuse.pod.mem.limit":"12Gi"}to increase the memory limit of the JindoFuse pod. Adjust the value based on available resources. For more information, see JindoFuse.-
Restore the connection:
For startup mounting, restart the DSW instance to restore the connection. The system automatically performs the mount again.
You can also run a dynamic mounting command by using the PAI SDK to remount the path without restarting the instance.
Q: What types of data can DSW mount? Can I directly mount Alibaba Cloud Drive or MaxCompute tables?
DSW supports OSS, NAS, and CPFS by creating a dataset or directly mounting a storage path.
Alibaba Cloud Drive is not supported: DSW does not support mounting a personal Alibaba Cloud Drive. We recommend that you store data that needs to be processed in OSS.
MaxCompute tables cannot be mounted: Data in MaxCompute (formerly ODPS) tables cannot be directly "mounted" to a DSW directory like a file system. You can read and write the data in your DSW code by using the SDK or API provided by PAI. For more information, see Read and write MaxCompute tables with PyODPS.
Q: Are code and data lost after a DSW instance is stopped or deleted? How do I persist and migrate data?
The system disk of a DSW instance is temporary storage. For a public resource group instance, data is cleared if the instance is stopped for more than 15 days. For a dedicated resource group instance, data on the system disk is also cleared after the instance is stopped or deleted.
To store data and code persistently and migrate them across instances, mount external storage.
Persistence: Save important data, code, and models in a mounted OSS or NAS path. Even if the DSW instance is deleted, your assets remain safely stored in OSS or NAS.
Migration: To migrate data from one DSW instance to another, mount the same OSS or NAS path to the new instance.
Q: How do I export data from the system disk if a DSW instance cannot be opened or started?
If a DSW instance cannot start due to insufficient resources or other reasons, the data on the system disk is not immediately lost. Try the following methods to export the data:
Change the instance specification and restart the instance: On the instance list page, click Change Configuration, select another available instance specification, and restart the instance. Changing the specification does not cause data loss on the system disk. After the instance starts, immediately back up the data to OSS or NAS.
Change the region or zone: If the current region has insufficient resources and your data is already stored in external storage, create a new instance and mount the same OSS/NAS storage to recover the data.
Contact technical support: If the preceding methods do not resolve the issue, submit a ticket to contact technical support for help with exporting the data.
If a public resource group instance is stopped for more than 15 days, the data on the free cloud disk is cleared and cannot be recovered. If you receive a notification that "The system disk will be released in X days", start the instance, for example by changing the specification, and back up the data before the deadline.
Q: Instance creation fails with a FAIL_TO_INIT_DATASET error.
If an OSS mount path points to a file instead of a directory, DSW detects during instance creation that the path cannot be identified as a directory, refuses to initialize the dataset, and returns the FAIL_TO_INIT_DATASET error. Check whether a file with the same name exists in the same directory as the OSS mount path. Delete the file or change the mount path to point to a valid directory, and then create the instance again.
Related documentation
For more FAQs, see DSW FAQ