Search code examples
c++bashcudanvidiamacos-high-sierra

Why can't clang find lnvrtc?


I am trying to get CUDA 9.2 running on high Sierra. I completed using the installer, and was trying to build the samples. When I run "make", some of the samples build without problem but when I try to build them all, I get the following error:

clang++  -rpath /Developer/NVIDIA/CUDA-9.2/lib -o clock_nvrtc clock.o  -lnvrtc
ld: library not found for -lnvrtc

If I go to:

cd /Developer/NVIDIA/CUDA-9.2/lib

I can see that I have the files:

libnvrtc-builtins.9.2.dylib
libnvrtc-builtins.dylib
libnvrtc.9.2.dylib      
libnvrtc.dylib

So I guess there must be some kind of environment variable / path issue.

The bash_profile file of mine is:

export PATH=/Developer/NVIDIA/CUDA-9.2/bin${PATH:+:${PATH}}

export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA9.2/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}

The output of running printenv in a new terminal is:

TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/gw/70bmspxd74j7fkfbvms8x22m0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.kptV0WXZcy/Render
TERM_PROGRAM_VERSION=404
TERM_SESSION_ID=47F46280-AEC0-4E23-8632-F6AA0422B14F
USER=kaizer
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.bhLK0n0mY9/Listeners
PATH=/Developer/NVIDIA/CUDA-9.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PWD=/Users/kaizer
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/kaizer
LOGNAME=kaizer
LC_CTYPE=UTF-8
_=/usr/bin/printenv

The output of running echo "$DYLD_LIBRARY_PATH":

/Developer/NVIDIA/CUDA9.2/lib

I have also installed Xcode command line tools, and am using Xcode 9.2 with High Sierra 10.13.6

I am trying to follow the instructions here: https://docs.nvidia.com/cuda/archive/9.2/cuda-installation-guide-mac-os-x/index.html#system-requirements

So what is the problem ? Why can't clang see the libraries ?


Solution

  • New versions of OS X enable system integrity protection per default. Meaning that setting the DYLD_LIBRARY_PATH and LD_LIBRARY_PATH will have no effects.

    See: https://github.com/nteract/nteract/issues/1523