Doesn't work if cuda is not installed in usr/local
See original GitHub issueIf cuda is not installed in ‘usr/local’, it does not run correctly. This is due to lines 42 and 46 in ops.py
Note also that lines 37-40 are not used in ops.py, and therefore neither is line 17 in config.ini.
My simple fix to this was to replace lines 37 to 46 in ops.py with the following:
out, err = subprocess.Popen(['which', 'nvcc'], stdout=subprocess.PIPE).communicate()
cuda_dir = out.decode().split('/cuda')[0]
nvcc_cmd = "nvcc -std=c++11 -c -o {} {} {} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -I " + cuda_dir + " --expt-relaxed-constexpr"
nvcc_cmd = nvcc_cmd.format(" ".join([fn_cu_o, fn_cu_cc]),
tf_inc, tf_lib)
subprocess.check_output(nvcc_cmd, shell=True)
gcc_cmd = "{} -std=c++11 -shared -o {} {} -fPIC -L " + cuda_dir + "/cuda/lib64 -lcudart {} -O2 -D GOOGLE_CUDA=1"
I also removed line 17 from config.ini
Finally, I know this is a custom config file, but I would also suggest perhaps changing line 15 in config.ini to
g++ = g++
I have tested on 3 different machines, all with different versions of linux, tensorflow, and cuda. With these small changes, your code runs immediately following a clone from this repo on all of them (after copying over the config.ini file of course.)
Just a few small suggestions to make things as out-the-box as possible! 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hi @DeckerDai ,
sorry about late. It has been a long time since I did not work on this problem. Previously I tried to run this repo then I moved to other projects. For my case, I only make the cuda version+cudnn version compatible with this repo. I am not quite sure about what other factors will have effects on compilation, for example, gcc. I suggest you can start to follow exactly the same versions used in this repo.
Thank you.
Many thanks! I changed the code as suggested. Sorry for taking so long to respond - I am very busy with new projects.