Manually Connecting to a Notebook Instance Through VS Code
A local IDE supports PyCharm and VS Code. You can use PyCharm or VS Code to remotely connect the local IDE to the target notebook instance on ModelArts for running and debugging code.
This section describes how to use VS Code to access a notebook instance.
Prerequisites
- You have downloaded and installed VS Code. For details, see Installing VS Code.
- Python has been installed on your local PC or server. For details, see VS Code official documentation.
- A notebook instance has been created with remote SSH enabled. Ensure that the instance is running. For details, see Creating a Notebook Instance.
- The address and port number of the development environment are available. To obtain the information, go to the notebook instance details page.
Figure 1 Instance details page
- The key pair is available.
A key pair is automatically downloaded after you create it. Securely store your key pair. If an existing key pair is lost, create a new one.
Step 1 Add the Remote-SSH Plug-in
In the local VS Code development environment, click , enter SSH in the search box, and click install of the Remote-SSH plug-in to install the plug-in.
Step 2 Configure SSH
- In the local VS Code development environment, click on the left, select SSH Targets from the drop-down list box, and click . The SSH configuration file path is displayed.
Figure 3 Configuring SSH Targets
- Click the SSH configuration path and configure SSH.
Figure 4 SSH configuration file path
HOST remote-dev hostname <Instance connection host> port <Instance connection port> user ma-user IdentityFile ~/.ssh/test.pem UserKnownHostsFile=/dev/null StrictHostKeyChecking no
- HOST: name of the cloud development environment
- HostName: address for accessing the cloud development environment. Obtain the address on the page providing detailed information of the target notebook instance.
- Port: port number for accessing the cloud development environment. Obtain the port number on the page providing detailed information of the target notebook instance.
- user: ma-user
- IdentityFile: locally stored private key file of the cloud development environment. It is the key pair file in Prerequisites.
- Return to the SSH Targets page, locate the target remote development environment, and click on the right to connect to host in a new window.
Figure 5 Opening the development environment
On the displayed page, click Linux.
Figure 6 Selecting a notebook running environment
Figure 7 Remote connection succeeded
Step 3 Install the Python Plug-in in the Cloud Development Environment
On the displayed VS Code page, click on the left, enter Python in the search box, and click Install.
If the Python plug-in fails to be installed on the cloud, install it using an offline package.
Step 4 Install the Dependent Library for the Cloud Environment
After accessing the container environment, you can use different virtual environments, such as TensorFlow and PyTorch. However, in actual development, you need to install dependency packages. Then, you can access the environment through the terminal to perform operations.
- In VS Code, press Ctrl+Shift+P.
- Search for Python: Select Interpreter and select the target Python.
- Choose . The CLI of the remote container is displayed.
- Run the following command to install the dependency package:
pip install spacy
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot