SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have packaged a library-only (non-Python) build of PyTorch (`-DBUILD_PYTHON=OFF` passed to `cmake`) for Slackware (using this SlackBuild), but now I'd like it to build the Python bindings, too.
It seems `-DBUILD_PYTHON=ON` would have created all the necessary files, but when I run `python3 setup.py install --root=$PKG`, it complains that I'm not in a `git` repo; I downloaded `pytorch-v2.3.0.tar.gz` to make the library-only package.
I have packaged a library-only (non-Python) build of PyTorch (`-DBUILD_PYTHON=OFF` passed to `cmake`) for Slackware (using this SlackBuild), but now I'd like it to build the Python bindings, too.
So basically I need to use Ninja, run "setup.py build" with the "--cmake-only" flag, and manually move the Python site-package stuff in tmpxxx.
In my case, I need
Code:
-DUSE_CUDA=ON \
-DUSE_CUDNN=ON \
and many other environment variables to specify my somewhat non-standard install locations for CUDA and CUDNN and that I need to use GCC 13.2 (∵ 14.1 isn't compatible with my CUDA version), but I can't find any binaries for 13.2 anymore (Slackware 15.0 uses GCC 11, and its GLIBC is too old for my CUDA version…)… Maybe I should just try CPU for now…
I get this, however:
Code:
-- Build files have been written to: /tmp/SBo/pytorch-v2.3.0/build
Building wheel torch-2.3.0a0+gitUnknown
-- Building version 2.3.0a0+gitUnknown
cmake -GNinja -DBUILD_PYTHON=True -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_FLAGS='--compiler-bindir=/home/geremia/gcc-11/usr/bin/ -I/home/geremia/gcc-11/usr/include/c++/11.2.0/ -L/home/geremia/gcc-11/usr/lib64/' -DCMAKE_CUDA_HOST_COMPILER=/home/geremia/gcc-11/usr/bin/g++ -DCMAKE_INSTALL_PREFIX=/tmp/SBo/pytorch-v2.3.0/torch -DCMAKE_PREFIX_PATH=/usr/lib/python3.11/site-packages;/usr/lib64 -DCUDA_HOST_COMPILER=/home/geremia/gcc-11/usr/bin/g++ -DCUDNN_INCLUDE_DIR=/usr/include -DCUDNN_LIBRARY=/usr/share/cuda/lib64/libcudnn.so -DJAVA_HOME=/usr/lib64/zulu-openjdk21 -DNUMPY_INCLUDE_DIR=/usr/lib64/python3.11/site-packages/numpy/core/include -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.11 -DPYTHON_LIBRARY=/usr/lib64/libpython3.11.so.1.0 -DTORCH_BUILD_VERSION=2.3.0a0+gitUnknown -DUSE_NNPACK=0 -DUSE_NUMPY=True /tmp/SBo/pytorch-v2.3.0
Finished running cmake. Run "ccmake build" or "cmake-gui build" to adjust build options and "python setup.py install" to build.
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
CMake Error: The source directory "/tmp/SBo/pytorch-v2.3.0/build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
So basically I need to use Ninja, run "setup.py build" with the "--cmake-only" flag, and manually move the Python site-package stuff in tmpxxx.
Almost. I updated the build on SBo similar to the patch above, https://slackbuilds.org/slackbuilds/...rch.SlackBuild
I suggest to build it as it comes from SBo with your custom setup, and see if it builds at all:
bash pytorch.SlackBuild |& tee build.log
Then make your CUDA adjustments to pytorch.SlackBuild and build again
bash pytorch.SlackBuild |& tee build.cuda.log
Then you can do a diff of build.log and build.cuda.log to identify problems.
I'm not sure how many of the CMake flags were really necessary, but my CUDA install is in somewhat non-standard directories. I definitely needed to set CUDAHOSTCXX / CMAKE_CUDA_HOST_COMPILER to a compatible GCC version (13.2 or earlier), though.
Code:
--- pytorch.SlackBuild 2024-05-24 21:53:28.000000000 -0700
+++ pytorch.SlackBuild.sbopkg 2024-05-25 19:57:42.231797290 -0700
@@ -63,6 +63,8 @@
SLKCFLAGS="-O2"
fi
+SLKCFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict"
+
set -e
rm -rf $PKG
@@ -85,12 +87,22 @@
# This seems harmless as these get recompiled again locally, but it slows down the building process.
# See https://github.com/icecc/icecream/issues/336
-export USE_NNPACK=0
+export USE_CUDA=1
+export CUDAHOSTCXX=/usr/bin/gcc-11
python3 setup.py build --cmake-only
cd build
unshare -n cmake \
-G Ninja \
+ -DCUDAToolkit_INCLUDE_DIR=/usr/include \
+ -DCUDA_CUDART_LIBRARY=/usr/lib64/libcudart.so \
+ -DCUDA_HOST_COMPILER=/usr/bin/gcc-11 \
+ -DCUDA_TOOLKIT_ROOT_DIR=/usr/share/cuda \
+ -DCUDNN_INCLUDE_DIR=/usr/include \
+ -DCUDNN_LIBRARY=/usr/share/cuda/lib64/libcudnn.so \
+ -DUSE_CUDA=ON \
+ -DUSE_CUDNN=ON \
+ -DUSE_NCCL=OFF \
-DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_CXX_STANDARD=17 \
{NCCL didn't build ∵ it seemed to ignore $CUDAHOSTCXX, so I disabled it. It's only required for inter-GPU communication (multiple GPUs).}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.