Setup Cerebras virtual environment#

To launch a job in the Cerebras cluster, you need to create a Python virtual environment with the Cerebras software dependencies. You need to create the virtual environment once (but only once) for every release (R1.8.0) and framework used (PyTorch or TensorFlow)


To setup the Cerebras virtual environment, the default path for Cerebras packages is /opt/cerebras/wheels

To setup the Cerebras virtual environment follow these steps

  1. Set up a Python virtual environment using Python 3.7. Create the environment named venv_cerebras_pt for a PyTorch environment or venv_cerebras_tf for a TensorFlow environment using the following command:

python3.7 -m venv venv_cerebras_pt


The name of the python3.7 executable may be different on your system (e.g, python, python3, python3.7, /opt/python3.7/bin/python3.7). Please ensure that you are using the correct name corresponding to the executable for python3.7.


If you install Python from source you need bzip2-devel and sqlite-devel installed on Linux or else you have a partial installation of python. That means many common python packages will fail with an error that looks like ModuleNotFoundError: No module named '_bz2'

  1. Cerebras provides three packages to set up virtual environments: cerebras_appliance software package, the cerebras_tensorflow package if you are using TensorFlow, and the cerebras_pytorch package if you are using PyTorch. To set up your PyTorch or TensorFlow environment, you need two out of these three packages. Enter the following commands to install the required packages.

source venv_cerebras_pt/bin/activate

pip install --upgrade pip

pip install <path_to_wheels>/cerebras_pytorch-<Cerebras release version>+<hash>-py3-none-any.whl --find-links=<path_to_wheels>

Note that the appliance wheel will be installed automatically by installing packages cerebras_pytorch or cerebras_tensorflow. The <path_to_wheels> by default is /opt/cerebras/wheels; if the path of the Cerebras packages is not the default one, use the location provided by your system administrator.


If your user node requires a proxy to access to external packages, you can add the flag --proxy <proxy address> to the pip commands to install the Cerebras packages.


With the find-links command, it finds the correct cerebras_appliance version if you place all the wheels in the same directory.


You can add custom packages to your Cerebras environment by: 1) pip install the packages in virtual environment, then 2) Copy the package directory from venv/lib/python3.7/site-packages/<package_name> to a NFS-mountable location in the Cerebras cluster. Make sure to add this location to the --mount_dirs command line argument and the corresponding parent location to the --python_paths command line argument when calling

Now you are all set and ready to train your first model on the Cerebras Wafer-Scale Cluster!