Installation#
Install the mhn package using pip#
Since the mhn package is largely written in Cython, a Cython-supported C compiler,
such as GCC or MSVC, must be installed on your device before you can install this package.
If that is the case, you can simply install the mhn package using pip:
pip install mhn
If the installation of mhn was successful, you should be able to import it with
import mhn
Use the CUDA implementation to accelerate computations#
If your device has an Nvidia GPU, you can accelerate the computation of the log-likelihood and its gradient for both the full and the restricted state space with CUDA. For that you have to have CUDA and the CUDA compiler installed on your device. You can check that in the terminal with
nvcc --version
If this command is recognized, then CUDA should be installed on your device.
During installation the package will automatically check if the CUDA compiler
is installed on your device and will enable the corresponding functions if this is the case.
While running a Python script you can test if the mhn package has access to GPU-accelerated
functions using the cuda_available() function as shown below:
import mhn
print(mhn.cuda_available())
# the three possible results are also available as constants:
# CUDA_AVAILABLE, CUDA_NOT_AVAILABLE, CUDA_NOT_FUNCTIONAL
if mhn.cuda_available() == mhn.CUDA_AVAILABLE:
print('CUDA is available')
if mhn.cuda_available() == mhn.CUDA_NOT_AVAILABLE:
print('CUDA compiler nvcc was not present during installation')
if mhn.cuda_available() == mhn.CUDA_NOT_FUNCTIONAL:
print('CUDA compiler nvcc available but CUDA functions not working. Check CUDA installation')
Pay special attention to the CUDA_NOT_FUNCTIONAL case. This indicates that while
the CUDA compiler is installed, basic functionalities like GPU memory allocation
are not working as expected. This likely points to an issue with your CUDA drivers,
so you should verify your CUDA installation.
If you cannot resolve CUDA_NOT_FUNCTIONAL by changing CUDA drivers, we recommend to install the package with CPU support only.
This can be accomplished on Linux via
export INSTALL_MHN_NO_CUDA=1
pip install mhn
and on Windows via
set INSTALL_MHN_NO_CUDA=1
pip install mhn
If you installed nvcc after installing the mhn package, you have to reinstall this package to gain access to the CUDA functions.