Skip to content

Commit 631f343

Browse files
authored
Merge pull request #25863 from lukstafi/conf-cuda-config
conf-cuda: CUDA libraries -- configure installation path, offer install tips, validate
2 parents ffa13bd + bb62d52 commit 631f343

File tree

2 files changed

+106
-0
lines changed
  • packages
    • conf-cuda-config/conf-cuda-config.1
    • conf-cuda/conf-cuda.1

2 files changed

+106
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
opam-version: "2.0"
2+
maintainer: "Lukasz Stafiniak <[email protected]>"
3+
authors: [
4+
"Lukasz Stafiniak <[email protected]>"
5+
]
6+
homepage: "https://docs.nvidia.com/cuda/"
7+
license: "MIT"
8+
build: [
9+
["sh" "-exc" """
10+
if [ -z "$CUDA_PATH" ]; then
11+
if [ -d "/usr/local/cuda" ]; then
12+
CUDA_PATH="/usr/local/cuda"
13+
CUDA_PREINSTALLED="true"
14+
elif [ -d "/opt/cuda" ]; then
15+
CUDA_PATH="/opt/cuda"
16+
CUDA_PREINSTALLED="true"
17+
elif [ -d "/usr/cuda" ]; then
18+
CUDA_PATH="/usr/cuda"
19+
CUDA_PREINSTALLED="true"
20+
elif [ "arch" = %{os-family}% ]; then
21+
CUDA_PATH="/opt/cuda"
22+
CUDA_PREINSTALLED="false"
23+
else
24+
CUDA_PATH="/usr/local/cuda"
25+
CUDA_PREINSTALLED="false"
26+
fi
27+
else
28+
if [ -d "$CUDA_PATH" ]; then
29+
CUDA_PREINSTALLED="true"
30+
else
31+
CUDA_PREINSTALLED="false"
32+
fi
33+
fi
34+
if [ -z "$WSL_DISTRO_NAME" ]; then
35+
IS_WSL="false"
36+
else
37+
IS_WSL="true"
38+
fi
39+
cat <<EOF > conf-cuda-config.config
40+
opam-version: "2.0"
41+
variables {
42+
cuda_preinstalled: "$CUDA_PREINSTALLED"
43+
cuda_path: "$CUDA_PATH"
44+
is_wsl: "$IS_WSL"
45+
wsl_distro_name: "$WSL_DISTRO_NAME"
46+
}
47+
EOF
48+
"""]
49+
]
50+
post-messages: [
51+
"NOTE: assuming CUDA will be installed under %{conf-cuda-config:cuda_path}%"
52+
{!conf-cuda-config:cuda_preinstalled}
53+
]
54+
synopsis: "Preparatory steps for the conf-cuda package"
55+
description:
56+
"This package checks if CUDA is already installed on the system, and if the OS runs under WSL."
57+
bug-reports: "https://github.com/ocaml/opam-repository/issues"
58+
flags: conf

packages/conf-cuda/conf-cuda.1/opam

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
opam-version: "2.0"
2+
maintainer: "Lukasz Stafiniak <[email protected]>"
3+
authors: [
4+
"NVidia"
5+
]
6+
homepage: "https://docs.nvidia.com/cuda/"
7+
license: "CUDA Toolkit End User License Agreement <https://docs.nvidia.com/cuda/eula/index.html>"
8+
# We do not restrict availability to let users install CUDA themselves.
9+
build: [
10+
["sh" "-exc" "cat <<EOF > test.c
11+
#include \"cuda.h\"
12+
#include \"nvrtc.h\"
13+
"]
14+
["sh" "-exc" "cc -c $CFLAGS -I%{conf-cuda-config:cuda_path}%/include test.c"]
15+
]
16+
# Note: the minimal set of packages directly from NVidia repositories, e.g. for cudajit:
17+
# "cuda-cudart-X-Y" "cuda-cudart-dev-X-Y" "cuda-runtime-X-Y" "cuda-nvrtc-X-Y" "cuda-nvrtc-dev-X-Y"
18+
# where e.g. X=12, Y=4 is the CUDA version.
19+
depends: [ "conf-cuda-config" ]
20+
setenv: [
21+
[ CUDA_PATH = "%{conf-cuda-config:cuda_path}%" ]
22+
]
23+
post-messages: [
24+
"Make sure that CUDA is properly installed under the path %{conf-cuda-config:cuda_path}%; or properly set the CUDA_PATH environment variable and re-install opam package conf-cuda-config. See: https://docs.nvidia.com/cuda/ Failing configuration: CUDA_PATH=%{conf-cuda-config:cuda_path}%, is-WSL %{conf-cuda-config:is_wsl}%, OS family %{os-family}%"
25+
{failure & conf-cuda-config:cuda_preinstalled}
26+
"Execute: $ sudo add-apt-repository multiverse; sudo apt update; sudo apt-get install nvidia-cuda-dev nvidia-cuda-toolkit"
27+
{failure & !conf-cuda-config:cuda_preinstalled & !conf-cuda-config:is_wsl & os-family = "debian" & os-distribution != "ubuntu"}
28+
"Execute: $ sudo apt-get install nvidia-cuda-dev nvidia-cuda-toolkit"
29+
{failure & !conf-cuda-config:cuda_preinstalled & !conf-cuda-config:is_wsl & os-distribution = "ubuntu"}
30+
"Under WSL, manually install CUDA. See https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#network-repo-installation-for-wsl"
31+
{failure & !conf-cuda-config:cuda_preinstalled & conf-cuda-config:is_wsl}
32+
"Execute: $ sudo zypper in CUDA CUDA-tools"
33+
{failure & !conf-cuda-config:is_wsl & !conf-cuda-config:cuda_preinstalled &
34+
(os-family = "opensuse" | os-distribution = "opensuse-leap" | os-distribution = "opensuse-tumbleweed")}
35+
"Execute: $ sudo pacman -Sy cuda"
36+
{failure & !conf-cuda-config:is_wsl & !conf-cuda-config:cuda_preinstalled & os-family = "arch"}
37+
"Alternatively: manually install CUDA or verify that CUDA_PATH is set properly, and re-install opam package conf-cuda-config. See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html"
38+
{failure & !conf-cuda-config:is_wsl & !conf-cuda-config:cuda_preinstalled & os = "linux"}
39+
"Manually install CUDA or verify that CUDA_PATH is set properly, and re-install opam package conf-cuda-config. See: https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html"
40+
{failure & !conf-cuda-config:is_wsl & !conf-cuda-config:cuda_preinstalled & os = "windows"}
41+
"If CUDA is supported on your system, manually install CUDA or verify that CUDA_PATH is set properly, and re-install opam package conf-cuda-config. See: https://docs.nvidia.com/cuda/"
42+
{failure & !conf-cuda-config:is_wsl & !conf-cuda-config:cuda_preinstalled & os != "linux" & os != "windows"}
43+
]
44+
synopsis: "Virtual package relying on a CUDA system installation"
45+
description:
46+
"This package can only install if CUDA is installed on the system."
47+
bug-reports: "https://github.com/ocaml/opam-repository/issues"
48+
flags: conf

0 commit comments

Comments
 (0)