This program is designed for verification of your LibTorch deployment. It is highly recommended using it on a CUDA-capable system.
After you have installed LibTorch by either
or
- following the instruction of INSTALLING C++ DISTRIBUTIONS OF PYTORCH to download a LibTorch ZIP archive,
you can use this program to verify your LibTorch installation.
Clone this repo and
cd <root-of-LibTorch_test>
mkdir -p build && cd build
If you build LibTorch from source, cmake
will take care of the rest.
cmake ..
Or, if you use LibTorch ZIP archive, please specify the absolute (!) path to the unzipped LibTorch distribution.
cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch/share/cmake ..
Then make
make -j$(nproc)
Now you can run it
./libtorch_test
If everything goes well, you should see output like
LibTorch version: 1.11.0
The following tensor is generated by cpu
0.3639 0.0979 0.2400
0.7631 0.3640 0.7143
[ CPUFloatType{2,3} ]
CUDA availability:True
cuDNN availability:True
This system has 2 CUDA-capable device(s).
The following tensor is generated by device cuda:0
0.6949 0.1144 0.9676
0.3724 0.5811 0.0785
[ CUDAFloatType{2,3} ]
The following tensor is generated by device cuda:1
0.0096 0.5464 0.3223
0.0522 0.9954 0.8502
[ CUDAFloatType{2,3} ]