How to install Lambda Stack on GPU server

One-line installation of TensorFlow, Keras, Caffe, CUDA, cuDNN, and NVIDIA Drivers for Ubuntu 16.04 and 18.04.

Ubuntu 18.04 / Ubuntu 16.04 desktop installation

Paste this command into a fresh Ubuntu installation to install Lambda stack on your desktop system. For servers, see the server installation section.

LAMBDA_REPO=$(mktemp) && \
wget -O${LAMBDA_REPO} https://lambdalabs.com/static/misc/lambda-stack-repo.deb && \
sudo dpkg -i ${LAMBDA_REPO} && rm -f ${LAMBDA_REPO} && \
sudo apt-get update && sudo apt-get install -y lambda-stack-cuda

after this, you’ll need to run sudo reboot to complete the installation.

What is Lambda Stack?

Lambda Stack provides an easy way to install popular Machine Learning frameworks. With Lambda Stack, you can use apt / aptitude to install TensorFlow, Keras, PyTorch, Caffe, Caffe 2, Theano, CUDA, cuDNN, and NVIDIA GPU drivers. If a new version of any framework is released, Lambda Stack manages the upgrade. You’ll never run into issues with your NVIDIA drivers again.

Lambda Stack is both a system wide package, a Dockerfile, and a Docker image.

No need to compromise. Lambda Stack is not only a system wide installation of all of your favorite frameworks and drivers but also a convenient “everything included” deep learning Docker image. Now you’ll have your team up and running with GPU-accelerated Docker images in minutes instead of weeks. To learn more about how to set up Lambda Stack GPU Dockerfiles check out our tutorial:
https://lambdalabs.com/blog/set-up-a-tensorflow-gpu-docker-container-using-lambda-stack-dockerfile/

Lambda Stack details

  • Works with Ubuntu 18.04 and 16.04
  • Supports nvidia-docker with the Lambda Stack Dockerfiles
  • Includes Deep Learning frameworks: TensorFlow, Keras, PyTorch, Caffe, Caffe 2
  • Includes GPU software: CUDA, cuDNN, NVIDIA drivers
  • Includes dev tools: git, tmux, screen, vim, emacs, htop, valgrind, build-essential

Lambda Stack Docker image creation for use with nvidia-docker

We’ve created Dockerfiles with a rolling release of Lambda Stack, designed for use with nvidia-docker. You can either follow our Lambda Stack GPU Docker tutorial here. Or, if you already have nvidia-docker installed you can build the Docker image immediately:

# Build a Docker image for Ubuntu 18.04 (bionic) or 16.04 (xenial) from our repository.
sudo docker build -t lambda-stack -f Dockerfile.$(lsb_release -cs) git://github.com/lambdal/lambda-stack-dockerfiles.git

Using Lambda Stack with python virtual environments

We’re often asked how to best use Lambda Stack with a python virtual environment. You have two choices: use Lambda Stack as a way to install CUDA, CuDNN, and NVIDIA drivers; or, use Lambda Stack as a way to manage TensorFlow and PyTorch as well as CUDA, CuDNN, NVIDIA drivers. Here’s how to do that:

python3 -m venv lambda-stack-with-tensorflow-pytorch --system-site-packages
. venv lambda-stack-with-tensorflow-pytorch/bin/activate

Here’s how to do it where the TensorFlow version is managed within the virtual environment:

python3 -m venv lambda-stack-without-tensorflow
. lambda-stack-without-tensorflow/bin/activate
pip install tensorflow-gpu

Ubuntu 16.04 server installation

For servers running Ubuntu 16.04 without a GUI (i.e. Ubuntu 16.04 server edition).

LAMBDA_REPO=$(mktemp) && \
wget -O${LAMBDA_REPO} https://lambdalabs.com/static/misc/lambda-stack-repo.deb && \
sudo dpkg -i ${LAMBDA_REPO} && rm -f ${LAMBDA_REPO} && \
sudo apt-get update && \
sudo apt-get --yes upgrade && \
sudo apt-get install --yes --no-install-recommends lambda-server && \
sudo apt-get install --yes --no-install-recommends nvidia-440 libcuda1-440 nvidia-opencl-icd-440 && \
sudo apt-get install --yes --no-install-recommends lambda-stack-cuda

Ubuntu 18.04 server installation

For servers running Ubuntu 18.04 without a GUI (i.e. Ubuntu 18.04 server edition).

LAMBDA_REPO=$(mktemp) && \
wget -O${LAMBDA_REPO} https://lambdalabs.com/static/misc/lambda-stack-repo.deb && \
sudo dpkg -i ${LAMBDA_REPO} && rm -f ${LAMBDA_REPO} && \
sudo apt-get update && \
sudo apt-get --yes upgrade && \
sudo apt-get install --yes --no-install-recommends lambda-server && \
sudo apt-get install --yes --no-install-recommends nvidia-headless-440 nvidia-utils-440 && \
sudo apt-get install --yes --no-install-recommends lambda-stack-cuda

Incorporating into shell scripts, Docker, Ansible, etc.

If you want to integrate Lambda Stack installation into a script, you’ll likely want to avoid all user input prompts. To use Lambda Stack in this way, you must have read and agreed to the CUDNN license.

LAMBDA_REPO=$(mktemp) && \
wget -O${LAMBDA_REPO} https://lambdalabs.com/static/misc/lambda-stack-repo.deb && \
sudo dpkg -i ${LAMBDA_REPO} && rm -f ${LAMBDA_REPO} && \
sudo apt-get update && \
sudo apt-get --yes upgrade && \
echo "cudnn cudnn/license_preseed select ACCEPT" | sudo debconf-set-selections && \
sudo apt-get install --yes --no-install-recommends lambda-server && \
sudo apt-get install --yes --no-install-recommends nvidia-440 libcuda1-440 nvidia-opencl-icd-440 && \
sudo apt-get install --yes --no-install-recommends lambda-stack-cuda

How to update / upgrade to the latest Lambda Stack version

Do this if a new version of TensorFlow (or any other framework) is released and you want to upgrade.

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove

This will upgrade all packages, including dependencies such as CUDA, cuDNN, and NVIDIA drivers.

Was this article helpful?

Related Articles