|
| 1 | + |
| 2 | +============ |
| 3 | +Installation |
| 4 | +============ |
| 5 | + |
| 6 | +Installing Using Pip |
| 7 | +-------------------- |
| 8 | + |
| 9 | +A pypi distribution of nuTens is provided, the page for which can be found `here <https://pypi.org/project/nuTens/>`_. |
| 10 | + |
| 11 | +This means that you can install nuTens via pip using the command |
| 12 | + |
| 13 | +.. code:: |
| 14 | +
|
| 15 | + pip install nuTens |
| 16 | +
|
| 17 | +
|
| 18 | +.. note:: |
| 19 | + |
| 20 | + The python interface can be installed manually after cloning the repository using pip by running |
| 21 | + |
| 22 | + .. code:: |
| 23 | + |
| 24 | + pip install . |
| 25 | + |
| 26 | + in the root directory of nuTens. |
| 27 | + |
| 28 | + This may be useful if you are developing nuTens. |
| 29 | + |
| 30 | + |
| 31 | +Installing From Source |
| 32 | +---------------------- |
| 33 | + |
| 34 | +Step 1 is to get your hands on a copy of the nuTens source code. |
| 35 | + |
| 36 | +To do this you can either clone the repository from github |
| 37 | + |
| 38 | +.. code:: |
| 39 | +
|
| 40 | + git clone git@github.com:ewanwm/nuTens.git |
| 41 | +
|
| 42 | +and checkout the release you want |
| 43 | + |
| 44 | +.. code:: |
| 45 | +
|
| 46 | + git checkout tags/v<X.Y.Z> |
| 47 | +
|
| 48 | +or visit the `releases <https://github.com/ewanwm/nuTens/releases>`_ page. |
| 49 | + |
| 50 | +Requirements |
| 51 | +^^^^^^^^^^^^ |
| 52 | + |
| 53 | +CMake |
| 54 | +""""" |
| 55 | +Should work with most modern versions. If you wish to use precompiled headers to speed up build times you will need CMake > 3.16. |
| 56 | + |
| 57 | +Compiler |
| 58 | +"""""""" |
| 59 | +Requires compiler with support for c++17 standard - Tested with gcc and clang |
| 60 | + |
| 61 | +PyTorch |
| 62 | +""""""" |
| 63 | +Currently pytorch is the only "backend" supported by nuTens. See https://pytorch.org/ for instructions on how to install it yourself, or you can use the requirements file provided as part of nuTens: |
| 64 | + |
| 65 | +.. code:: |
| 66 | +
|
| 67 | + pip install -r PyTorch_requirements.txt |
| 68 | +
|
| 69 | +Building |
| 70 | +^^^^^^^^ |
| 71 | + |
| 72 | +Create a build directory |
| 73 | + |
| 74 | +.. code:: |
| 75 | +
|
| 76 | + mkdir build |
| 77 | + cd build |
| 78 | +
|
| 79 | +Configure using cmake (see :ref:`cmake-config-options` for more information on available build options). |
| 80 | +One particularly important option to be aware of here is ``NT_ENABLE_PYTHON=<ON/OFF>`` which determines whether or not to build the nuTens python interface. |
| 81 | + |
| 82 | +.. note:: |
| 83 | + If you build the python interface using this method (specifying ``-DNT_ENABLE_PYTHON=ON`` during cmake configuration) you will need to tell python where it can find the nuTens python module by setting the ``PYTHONPATH`` environment variable: |
| 84 | + |
| 85 | + .. code:: |
| 86 | +
|
| 87 | + export PYTHONPATH=<path to nuTens build directory>:$PYTHONPATH |
| 88 | +
|
| 89 | +.. code:: |
| 90 | +
|
| 91 | + cmake -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` <path to source code> |
| 92 | +
|
| 93 | +Now build! |
| 94 | + |
| 95 | +.. code:: |
| 96 | +
|
| 97 | + make <-j Njobs> && make install |
| 98 | +
|
| 99 | +Verifying Your Installation |
| 100 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 101 | + |
| 102 | +Once you've installed nuTens, you can verify your installation by running |
| 103 | + |
| 104 | +.. code:: |
| 105 | +
|
| 106 | + make test |
| 107 | +
|
| 108 | +and (if you have installed the python interface) |
| 109 | + |
| 110 | +.. code:: |
| 111 | +
|
| 112 | + pip install pytest |
| 113 | + pytest tests |
| 114 | +
|
| 115 | +Known Issues |
| 116 | +------------ |
| 117 | + |
| 118 | +When trying to run using the python interface you may get complaints relating to not being able to locate `libtorch.so` or `libtorch_cpu.so` library files. If so running |
| 119 | + |
| 120 | +.. code:: |
| 121 | + |
| 122 | + export LD_LIBRARY_PATH=`python3 -c 'import os;import torch;print(os.path.abspath(torch.__file__)[:-11])'`/lib:$LD_LIBRARY_PATH |
| 123 | +
|
| 124 | +
|
| 125 | +should allow these files to be found |
| 126 | + |
| 127 | + |
| 128 | +.. _cmake-config-options: |
| 129 | + |
| 130 | +CMake Configuration Options |
| 131 | +--------------------------- |
| 132 | + |
| 133 | +========================== ============================================================================ ======= |
| 134 | +Option Description Default |
| 135 | +========================== ============================================================================ ======= |
| 136 | +NT_USE_TORCH Use torch as the backend for dealing with tensors ON |
| 137 | +NT_TORCH_FROM_PIP If it is not found, torch will be installed using pip ON |
| 138 | +NT_ALLOW_GLOBAL_PYTHON_ENV Allow installing pip packages in global python environment (Not recommended) OFF |
| 139 | +NT_COMPILE_TESTS Whether or not to compile the test library ON |
| 140 | +NT_ENABLE_PYTHON Enable compilation of the python interface OFF |
| 141 | +========================== ============================================================================ ======= |
| 142 | + |
| 143 | +For Developers |
| 144 | +^^^^^^^^^^^^^^ |
| 145 | + |
| 146 | +These options are a bit more "advanced" and probably only of interest to anyone actually writing nuTens library code. |
| 147 | + |
| 148 | +====================== ===================================================================================================================================================================================== ======= |
| 149 | +Option Description Default |
| 150 | +====================== ===================================================================================================================================================================================== ======= |
| 151 | +NT_TORCH_FROM_SCRATCH If it is not found, torch will be compiled from scratch using CPM (very slow but maybe useful for debugging builds) OFF |
| 152 | +NT_ENABLE_BENCHMARKING Whether or not to compile benchmark executables OFF |
| 153 | +NT_BUILD_TIMING Whether or not to time the build process OFF |
| 154 | +NT_LOG_LEVEL Set the log level to one of <SILENT ERROR WARNING INFO DEBUG TRACE> INFO |
| 155 | +NT_PROFILING Enable profiling (see :ref:`profiling`) OFF |
| 156 | +NT_TEST_COVERAGE Add flags to allow checking of test coverage OFF |
| 157 | +NT_USE_PCH Use precompiled headers to speed up the build process OFF |
| 158 | +BUILD_SHARED_LIBS Whether or not to build shared libraries or static (not compatible with NT_ENABLE_PYTHON which requires static libraries. If both are specified BUILD SHARED_LIBS will be set to OFF) ON |
| 159 | +====================== ===================================================================================================================================================================================== ======= |
| 160 | + |
| 161 | +Building Against nuTens |
| 162 | +----------------------- |
0 commit comments