# Using Virtual Environments with Lambda Stack

**URL:** <https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454>\
**Category:** Uncategorized\
**Created:** [August 22, 2018, 5:30pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454 "2018-08-22T17:30:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johann](https://sea1.discourse-cdn.com/flex019/user_avatar/deeptalk.lambda.ai/johann/32/596_2.png) [@Johann](https://deeptalk.lambda.ai/u/Johann)\
**Post date:** [August 22, 2018, 5:30pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/1 "2018-08-22T17:30:45Z")

</div>

I am using the Tensorbook, which comes with the preinstalled libraries as part of the Lambda Stack, but I don’t want to be developing in the root environment and want to create a new Virtual Environment.

Is there a best practices for this, or commands, or recommended process to get the Lambda Stack for virtual environments?

---

<div class="post-metadata">

**Author:** ![sabalaba](https://sea1.discourse-cdn.com/flex019/user_avatar/deeptalk.lambda.ai/sabalaba/32/4_2.png) [@sabalaba](https://deeptalk.lambda.ai/u/sabalaba)\
**Post date:** [August 22, 2018, 9:49pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/2 "2018-08-22T21:49:13Z")

</div>

We’re still establishing the best practices. There are two main choices I see:

1. Use Lambda Stack as an easy way to install your Drivers, CUDA, CuDNN, etc.
2. Use Lambda Stack’s version of TensorFlow / PyTorch.

If you decide to go for type 1, you’ll simply install Lambda Stack and then create your virtualenv like this:

```
virtualenv -p python3 your_venv

```

If you decide to go for type 2, you’ll install Lambda Stack and then create your virtualenv like this:

```
virtualenv --system-site-packages -p python3 your_venv

```

Essentially in type 2 you’ll be using our TensorFlow / PyTorch packages and type 1 you’ll be installing them yourself.

---

<div class="post-metadata">

**Author:** ![msuttles](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@msuttles](https://deeptalk.lambda.ai/u/msuttles)\
**Post date:** [August 12, 2019, 4:50pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/3 "2019-08-12T16:50:28Z")

</div>

Since this is from about a year ago, I wondered if you could update if there are now best practices for virtual environments? Thanks.

---

<div class="post-metadata">

**Author:** ![saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@saurabh](https://deeptalk.lambda.ai/u/saurabh)\
**Post date:** [November 13, 2020, 6:19pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/4 "2020-11-13T18:19:19Z")

</div>

Are there any updates on this?

---

<div class="post-metadata">

**Author:** ![rneely](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@rneely](https://deeptalk.lambda.ai/u/rneely)\
**Post date:** [July 8, 2021, 6:07pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/5 "2021-07-08T18:07:01Z")

</div>

@sabalaba Thank you. If we use the 2nd option:  
virtualenv --system-site-packages -p python3 your\_venv  
and then install additional packages from an additional requiremnts.txt file  
would the additional packages be installed in the venv, or where system site packages are installed?

I have a lambda-labs tensor book.  
We want to use Data Science cookie cutter for our project: [Home - Cookiecutter Data Science](https://drivendata.github.io/cookiecutter-data-science/) which suggests, as a best practice, to have a separate python venv for each project.

---

<div class="post-metadata">

**Author:** ![rajatalak](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@rajatalak](https://deeptalk.lambda.ai/u/rajatalak)\
**Post date:** [September 15, 2021, 3:46pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/6 "2021-09-15T15:46:10Z")

</div>

Is there a way to do this (option 2) using IDE like PyCharm?

---

<div class="post-metadata">

**Author:** ![markd](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@markd](https://deeptalk.lambda.ai/u/markd)\
**Post date:** [October 25, 2021, 8:39pm UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/7 "2021-10-25T20:39:00Z")

</div>

@rajatalak ajatalak

Here is the two ways that PyCharm seems to support VirtualEnv:

1. It can use a existing virtualenv
2. It can create a virtualenv

Documents at:  
[Configure a virtual environment | PyCharm Documentation](https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html#python_create_virtual_env)

Mark

---

<div class="post-metadata">

**Author:** ![wgiersche](https://sea1.discourse-cdn.com/flex019/user_avatar/deeptalk.lambda.ai/wgiersche/32/594_2.png) [@wgiersche](https://deeptalk.lambda.ai/u/wgiersche)\
**Post date:** [September 12, 2022, 2:46am UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/8 "2022-09-12T02:46:27Z")

</div>

Is there any way to achieve the same with pipenv?

---

<div class="post-metadata">

**Author:** ![markd](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@markd](https://deeptalk.lambda.ai/u/markd)\
**Post date:** [September 15, 2022, 6:13am UTC](https://deeptalk.lambda.ai/t/using-virtual-environments-with-lambda-stack/454/9 "2022-09-15T06:13:45Z")

</div>

It should be pretty much the same. (but below are the ones we have written up)

We have documented this for:  
- Docker - [NVIDIA NGC Tutorial: Run a PyTorch Docker Container using nvidia-container-toolkit on Ubuntu](https://lambdalabs.com/blog/nvidia-ngc-tutorial-run-pytorch-docker-container-using-nvidia-container-toolkit-on-ubuntu/)  
- python venv - [https://lambdalabs.com/blog/p/120e0f36-3dc2-4164-be0d-9c80705017e7/](https://lambdalabs.com/blog/p/120e0f36-3dc2-4164-be0d-9c80705017e7/)  
- virtualenv - [https://lambdalabs.com/blog/p/8060fba4-4ab4-464c-a829-d8fc917fcb1a/](https://lambdalabs.com/blog/p/8060fba4-4ab4-464c-a829-d8fc917fcb1a/)  
- Anaconda/miniconda - [Setting up environments: Anaconda](https://lambdalabs.com/blog/setting-up-a-anaconda-environment/)  
(I missed the step in this that I installed cuDNN or you could use the anaconda path).  
\* Anaconda is missing a step of setting the LD\_LIBRARY\_PATH for its cuDNN so that  
needs to be manually done. (The following will fix that):  
export LD\_LIBRARY\_PATH=${CONDA\_PREFIX}/lib:${LD\_LIBRARY\_PATH}

I hope that helps
