Help Center> ModelArts> Docker Containers with ModelArts> FAQs> How Do I Configure a Conda Source in a Notebook Development Environment?
Updated on 2024-06-12 GMT+08:00

How Do I Configure a Conda Source in a Notebook Development Environment?

You can install the development dependencies in Notebook as you need. Package management tools pip and Conda can be used to install regular dependencies. The pip source has been configured and can be used for installation, while the Conda source requires further configuration.

This section describes how to configure the Conda source on a notebook instance.

Configuring the Conda Source

The Conda software has been preset in images.

Common Conda Commands

For details about all Conda commands, see Conda official documents. The following table lists only common commands.

Table 1 Common Conda commands

Description

Command

Obtain online help.

conda --help
conda update --help # Obtain help for a command, for example, update.

View the Conda version.

conda -V

Update Conda.

conda update conda  # Update Conda.
conda update anaconda # Update Anaconda.

Manage environments.

conda env list  # Show all virtual environments.
conda info -e # Show all virtual environments.
conda create -n myenv python=3.7 # Create an environment named myenv with Python version 3.7.
conda activate myenv  # Activate the myenv environment.
conda deactivate  # Disable the current environment.
conda remove -n myenv --all # Delete the myenv environment.
conda create -n newname --clone oldname # Clone the old environment to the new environment.

Manage packages.

conda list  # Check the packages that have been installed in the current environment.
conda list  -n myenv  # Specify the packages installed in the myenv environment.
conda search numpy # Obtain all information of the numpy package.
conda search numpy=1.12.0 --info  # View the information of NumPy 1.12.0.
conda install numpy pandas  # Concurrently install the NumPy and Pandas packages.
conda install numpy=1.12.0  # Install NumPy of a specified version.
# The install, update, and remove commands use -n to specify an environment, and the install and update commands use -c to specify a source address.
conda install -n myenv numpy  # Install the numpy package in the myenv environment.
conda install -c https://conda.anaconda.org/anaconda numpy  # Install NumPy using https://conda.anaconda.org/anaconda.
conda update numpy pandas   # Concurrently update the NumPy and Pandas packages.
conda remove numpy pandas   # Concurrently uninstall the NumPy and Pandas packages.
conda update –-all # Update all packages in the current environment.

Clear Conda.

conda clean -p      # Delete useless packages.
conda clean -t      # Delete compressed packages.
conda clean -y --all # Delete all installation packages and clear caches.

Saving as an Image

After installing the external libraries, save the environment using the image saving function provided by ModelArts notebook of the new version. You can save a running notebook instance as a custom image with one click for future use. After the dependency packages are installed on a notebook instance, it is a good practice to save the instance as an image to prevent the dependency packages from being lost. For details, see Saving a Notebook Environment Image.