Skip to content

Installation

SaltyChiang edited this page Jun 23, 2024 · 5 revisions

Prerequisites

  • OpenMPI/MPICH2
  • Python >= 3.7
    • cython>=3
    • numpy
    • mpi4py
    • cupy>=12 (optional)
    • torch (optional)
    • mpi4py
  • QUDA
    • CMake >= 3.18
    • Git
    • GCC/Clang (supports C++17)
    • CUDA Toolkit >= 11

For detailed instructions to set the environment, refer to https://github.com/CLQCD/PyQUDA/wiki/Environment.

Build and install QUDA

git clone https://github.com/lattice/quda.git
mkdir -p quda/build
pushd quda/build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RELEASE \
    -DQUDA_GPU_ARCH=sm_60 -DQUDA_MPI=ON \
    -DQUDA_COVDEV=ON -DQUDA_LAPLACE=ON -DQUDA_MULTIGRID=ON \
    -DQUDA_CLOVER_DYNAMIC=OFF -DQUDA_CLOVER_RECONSTRUCT=OFF \
    -DQUDA_DIRAC_CLOVER_HASENBUSCH=OFF -DQUDA_DIRAC_DOMAIN_WALL=OFF \
    -DQUDA_DIRAC_TWISTED_CLOVER=OFF -DQUDA_DIRAC_TWISTED_MASS=OFF \
    -DQUDA_DIRAC_NDEG_TWISTED_CLOVER=OFF -DQUDA_DIRAC_NDEG_TWISTED_MASS=OFF
cmake --build . -j32 && cmake --install .
popd

The QUDA_GPU_ARCH term should be set to the architecture of your device. The default installation path of QUDA will be /path/to/quda/build/usqcd. PyQUDA will use this path then.

Install CuPy or PyTorch

PyQUDA requires cupy or torch to handle the data on GPU memory.

Choose ONE OF the commands below depending on your CUDA toolkit version to install cupy.

python3 -m pip install "cupy>=12" # build from source, not recommend
python3 -m pip install "cupy-cuda110>=12" # for CUDA v11.0
python3 -m pip install "cupy-cuda111>=12" # for CUDA v11.1
python3 -m pip install "cupy-cuda11x>=12" # for CUDA v11.2 ~ v11.8
python3 -m pip install "cupy-cuda12x>=12" # for CUDA v12.x

Or use the command blow to install torch.

python3 -m pip install "torch>=2"

Install PyQUDA

git clone --recursive https://github.com/CLQCD/PyQUDA.git
pushd PyQUDA
export QUDA_PATH=/path/to/quda/build/usqcd
python3 -m pip install .
popd

Here we use an environment variable QUDA_PATH to tell PyQUDA where to find the libquda.so.

Test the installation

Chroma is needed to generate the reference files used by test scripts.

A precompiled chroma executable for most Linux distros is included in the repository, and you need to fetch it with git-lfs. Note that git<2 seems not to work well with git-lfs.

git lfs install
git lfs pull

The reference files used by test scripts should be generated by running Chroma with test.*.ini.xml. Then the corresponding Python script test.*.py will check the QUDA result with Chroma.

tests/bin/chroma -i tests/test.clover.ini.xml
python3 tests/test.clover.py

Or just run the Python script which automatically calls Chroma.

python3 tests/test.clover.chroma.py

You may also want to initialize pyquda with command line arguments instead of hardcoding init parameters in scripts.

python3 -m pyquda tests/test.clover.cli.py --lattice 4 4 4 8 --t-boundary -1 --anisotropy 2.593684210526316 --backend cupy

The command line with arguments above is written in the shebang line.

./tests/test.clover.cli.py
Clone this wiki locally