Installation FAQs#

How to install TRAK?#

Our package is hosted on PyPI. The standard version of our package can be installed using

pip install traker

To install the version of our package which contains a fast, custom CUDA kernel for the JL projection step, use

pip install traker[fast]

pip will compile our CUDA kernel on your machine. For this to happen, you need to have compatible versions of gcc and CUDA toolkit. See the sections below for tips regarding this.

Confirm your TRAK installation using

>>> import trak
>>> trak.test_install(use_fast_jl=False)

and your fast_jl installation using

>>> trak.test_install(use_fast_jl=True)

How to install nvcc (CUDA toolkit)?#


Version required: CUDA >= 10.0.

Pick one option:

  • Some machines might already have been setup with the CUDA toolkit. You can run

    nvcc --version

    in a terminal and check if it already exists. If you have a compatible version then you can proceed with the TRAK installation.

  • If you are logged in an unversity/company shared cluster, there is most of the time a way to enable/load a version of CUDA tookit without having to install it. On clusters using modulefile, the command

    module avail

    will show you what is available to you. When in doubt, plese refer to the maintainers/documentation of your cluster.

  • Using conda:

    conda install -c conda-forge cudatoolkit-dev

    Note that the version of CUDA toolkit on the conda index may be outdated.

  • If you are root on your machine or feel confident with configuring the installation you can follow Nvidia instructions:

How to install gcc?#


Version required: If you have CUDA 11, you will need gcc with version 7.5 <= version <= 10. For CUDA 12, you will need gcc with version >= 7.5.

Pick one option:

  • Most Operating System come with gcc preinstalled. You can run

    gcc --version

    in a terminal to check if it’s the case on your machine and which version you have. If you have a compatible version then you can proceed with the TRAK installation.

  • If your operating ships with an incompatible compiler they usually let you install other version alongside what comes by default. Here is an example for ubuntu and gcc 10: 1. Add repository:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    1. Update list of packages:

    sudo apt update
    1. Download/install gcc 10:

    sudo apt install gcc-10 g++-10
    1. Enable the compiler before runing pip install traker[fast]:


    This has to be done in the same terminal.

    export CXX=g++10 CC=gcc-10

Running the tests#

You can test your installation by running the following in a python shell:

>>> import trak
>>> trak.test_install(use_fast_jl=False)
>>> trak.test_install(use_fast_jl=True)  # if you're using the fast version

If you want to run any of the tests in the tests directory, you need to install the optional [tests] dependencies:

pip install traker[tests]

Then you can run the tests using

python -m pytest -sv tests/

Misc Q&A#

Q: I’m using zsh and when running pip install traker[fast], I get

zsh: no matches found: traker[fast]

A: Make sure to escape the square brackets, i.e. run

pip install traker\[fast\]