Persisting Python Dependencies in a Dev Pod with a Conda Environment
Learn how to persist data and Python dependencies between jobs or in a dev pod with a Conda environment in DGX Cloud Lepton.
Conda is known for its ability to create isolated environments for different projects. When running jobs on DGX Cloud Lepton, you can use Conda to ensure your code runs with the exact dependencies needed, making your workloads more reliable and reproducible.
Here is an example of running a job with Conda environment management on DGX Cloud Lepton.
Prepare the Conda environment
The following example assumes you have already set up a Dev Pod running with a Conda-installed image and filesystem mounted at /mnt.
The filesystem mounted at /mnt is needed to persist data between different dev pods and/or jobs and/or between starting and stopping a dev pod. Any data downloaded or saved in this example or environment should be saved in /mnt. If this filesystem does not exist, any data saved in the dev pod will not be persisted if the pod is stopped.
If you do not have Conda installed in your container image (such as if using the ubuntu:24.04 image), you can run the following commands in the web terminal of the pod after starting the pod to install Conda. However, to complete the example, you will need to create or use a base container image with Conda already installed. For an example of how to build a container image, see the Build Container Image example.
Once the pod is running and conda is installed, you can then create a Conda environment with PyTorch and pack it to the filesystem.
In the web terminal of the dev pod, run the following commands:
The foo.tar.gz file contains the Conda environment, saved in /mnt.
Create a Job with Conda environment
You can then run another dev pod, and load the Conda environment in the pod by running the following commands in the web terminal once started. You can also run the following commands in a batch job which will run to completion by specifying the following commands in the Run Command section during job configuration.
Make sure Conda is installed in the container image, and the same shared filesystem is mounted at /mnt.
Once the job is created, you can view the job logs in the dashboard.
For future/additional jobs, you can create the job following the instructions above to activate the same conda environment across different jobs.