Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Latest commit

 

History

History
156 lines (104 loc) · 5.05 KB

File metadata and controls

156 lines (104 loc) · 5.05 KB

Enable EFS Access point on SageMaker Notebook

Summary

This section will enable EFS Access point you created in the previous section on the SageMaker Notebook instance. Lets begin by checking if the EFS file system has been successfully mounted on the SageMaker Notebook instance. This step was automatically completed when you created the workshop environment.

Duration

Note
It will take approximately 15 minutes to complete this section.

Step-by-step Guide

Check EFS file system mount on sagemaker notebook instance

Important
Read through all steps below and watch the quick video before continuing.
03 enable access point
  1. Open the Amazon SageMaker console.

    Tip
    Context-click (right-click) the link above and open the link in a new tab or window to make it easy to navigate between this github tutorial and the Amazon SageMaker console.
  2. Go to Notebook and Click Notebook instances.

  3. Select the notebook instance named efs-datascience-workshop then Click Open Jupyter.

  4. Go to top right corner Select New >> Terminal.

  5. Copy the script below into your notebook terminal window.

    mount -t nfs4
  6. You should see the EFS file system mounted on the notebook instance. An example output has been shown below:

    127.0.0.1:/ on /home/ec2-user/SageMaker/efs type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,noresvport,proto=tcp,port=20197,timeo=600,retrans=2,sec=sys,clientaddr=127.0.0.1,local_lock=none,addr=127.0.0.1)
  7. Go to Notebook Select Lifecycle configurations.

  8. Select the Lifecycle configuration created as part of this tutorial.

  9. Go to Scripts Click View script under Start Notebook. You will see the script that was executed to mount the EFS file system upon start of the Notebook.

  10. Click Close Go to Scripts Click View script under Create Notebook. You will see the script that was executed upon creation of the Notebook.

  11. Click Close and Go to the Notebook terminal window

  12. Copy the script below into your notebook terminal window.

    cd SageMaker/efs
    
    # Check the directory permission
    ls -ld .
    
    # Check your user ID
    id
    
    #Create a test file
    echo "Creating test file" >> datascience-tutorial-testfile
  13. What behavior did you observe?

  14. The /home/ec2-user/SageMaker/efs mount path is owned by root:root with permissions 755. You recieved a permisson denied error when you attempted to create a new file because the posix permissions on the directory prevented you from creating a new file as ec2-user. Data Science teams need the flexibility to access shared notebooks and EFS Access points makes this possible.

  15. Copy the script below in your notebook terminal window to create a test directory in the EFS file system root.

    sudo mkdir datascience-test-dir
    ls -ld datascience-test-dir
  16. Copy the script below into your notebook terminal window. Replace the Access point name with the one you created in previous section and file ssytem DNS name with the file system for your lab

    cd
    sudo umount /home/ec2-user/SageMaker/efs
    sudo mount -t efs -o tls,accesspoint=<Access point> <EFS file system DNS name>:/ /home/ec2-user/SageMaker/efs
    Ex: sudo mount -t efs -o tls,accesspoint=fsap-07228bb71d33e2b23 fs-ba453210.efs.us-west-2.amazonaws.com:/ /home/ec2-user/SageMaker/efs
  17. Copy the script below into your notebook terminal window.

    cd /home/ec2-user/SageMaker/efs
    ls
  18. Since you specified /notebooks as the path for your Access point, this directory will be created and mounted as root of your EFS mount. You can no longer see the test directory datascience-test-dir that you had created earlier. Next let’s see if you can create files in /home/ec2-user/SageMaker/efs mount path using your user id ec2-user.

    echo "Creating test file" >> datascience-tutorial-testfile
    cat datascience-tutorial-testfile
    ls -lt datascience-tutorial-testfile
  19. You were able to create the file successfully as ec2-user:ec2-user. All files will inherit 1001:1001 and 755 permissions that you defined at the time of Access point creation. Using EFS Access Point you were able, you were now able to create files on the shared notebook directory and make this directory available to data scientists and users.

  20. Finally lets create a directory to store your training dataset and download the MNIST dataset in recordIO format.

    cd /home/ec2-user/SageMaker/efs
    mkdir training
    cd training
    aws s3 cp  s3://amazon-elastic-file-system/tutorial/datascience/DEMO-linear-mnist/train/recordio-pb-data recordio-pb-data
  21. Continue with the next section.

Next section

Click the button below to go to the next section.

04 run ml training