Compiling using nvcc gives "No such file or directory" - c++

I'm trying to compile CUDA code using nvcc on Ubuntu. However, when I do, I get this output:
> make
/usr/local/cuda/bin/nvcc -m64 --ptxas-options="-v" -gencode arch=compute_11,code=sm_11 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -o main main.cu
gcc: No such file or directory
make: *** [main] Error 1
Even when I'm trying to compile a file with only a main function in it, it still doesn't work:
> /usr/local/cuda/bin/nvcc main.cu
gcc: No such file or directory
nvcc seems to respond to --version, so it's definitely there. I'm not sure why it's invoking gcc though.

nvcc is not a compiler in itself. It's a "compiler driver", orchestrating the entire process of compiling device code, host code and linking it together. On Linux, it uses gcc for compiling the host code.
To install gcc on Ubuntu:
$ sudo apt-get --yes install build-essential

Related

geos: No such file or directory

I am trying to use the geos library on a Raspbery Pi 3, using Debian. I am trying to compile a program in C ++.
The same program can be compiled on other computers, this means that the source code of my program is correct.
When executing the command geos-config --version, version 3.7.1 is returned to me.
A while ago, a friend compiled and has been using the same code in Raspibian. However, I can't run it on Debian. My friend does not remember how he installed the geos library.
Would anyone know of anything that could help me?
make
Building target using GCC compiler: sources/geometry-manager.cpp
g++ -g -c sources/geometry-manager.cpp -std=c++17 -w -c -rdynamic -W `wx-config --cxxflags --libs --gl-libs` `geos-config --cflags` -lgeos -lglut -lGLU -lGL -lm -lGLEW -o builded/geometry-manager.o `pkg-config --libs geographiclib`
In file included from sources/geometry-manager.cpp:14:
sources/../include/geometry-manager.hpp:26:10: fatal error: geos.h: No such file or directory
#include <geos.h>
^~~~~~~~
compilation terminated.
make: *** [Makefile:37: builded/geometry-manager.o] Error 1
geos-config --includes : /usr/include.
geos-config --cflags : -I/usr/include.
geos-config --libs : -L/usr/lib/aarcg64-linux-gnu -lgeos-3.7.1 .
I installed via apt-get. However, as it didn't work, I installed it from the cloned github repository. –
Solution:
I uninstalled geos from my computer. Afterwards, I deleted all the folders related to geos that were still on the computer.
For some reason, the installation from the current repository did not work. So I cloned an old version of the geos.
https://github.com/libgeos/geos.git
I ran autogen.sh script (which didn't work before).
And this time it compiled and installed it successfully.
Thanks

gRPC doesn't produce libraries for c++ on ubuntu

When I tried to run example of gRPC for c++ in folder grpc/examples/cpp/helloworld it requires libraries which weren't compiled when I built gRPC with Cmake
Firstly I built gRPC in Ububtu 16.04 with instructions:
$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
$ cd third_party/protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure --prefix=/usr
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
$ pkg-config --cflags protobuf # print compiler flags
$ pkg-config --libs protobuf # print linker flags
$ pkg-config --cflags --libs protobuf # print both
cd ../..
make
sudo make install
After that I tried to run example in folder grpc/examples/cpp/helloworld
grps/grpc/examples/cpp/helloworld$ make
i got several mistakes, which were resolved by copying grpc_cpp_plugin from folder grpc/bins/opt to /usr/local/bin and grpc++.pc and grpc++_unsecure.pc from grpc/libs/opt/pkgconfig/ to /usr/local/lib/pkgconfig.
When I tried for the next time command
grpc/examples/cpp/helloworld$ make
I've got message
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_client.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -pthread -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_client
/usr/bin/ld: cannot find -lgrpc++
/usr/bin/ld: cannot find -lgrpc++_reflection
collect2: error: ld returned 1 exit status
Makefile:44: recipe for target 'greeter_client' failed
make: *** [greeter_client] Error 1
So, I searched these libs libgrpc++ in folder grpc/libs/opt, but there only these libraries
grpc/libs/opt$ ls --l
libaddress_sorting.a libgrpc_cronet.so.8
libaddress_sorting.so libgrpc_cronet.so.8.0.0
libaddress_sorting.so.8 libgrpc_plugin_support.a
libaddress_sorting.so.8.0.0 libgrpc.so
libares.a libgrpc.so.8
libboringssl.a libgrpc.so.8.0.0
libgpr.a libgrpc_unsecure.a
libgpr.so libgrpc_unsecure.so
libgpr.so.8 libgrpc_unsecure.so.8
libgpr.so.8.0.0 libgrpc_unsecure.so.8.0.0
libgrpc.a pkgconfig
libgrpc_cronet.a protobuf
libgrpc_cronet.so
So make didn't compile static and dynamic libraries for gRPC. Is it I did something wrong or didn't something or there is a bug? Version of protobuf is
:~$ protoc --version
libprotoc 3.8.0
:~$ which protoc
/usr/bin/protoc
Here is some output after I run "make" from root directory
[MAKE] Generating /home/user/cpp_test/grps/grpc/libs/opt/pkgconfig/grpc++.pc
[MAKE] Generating /home/user/cpp_test/grps/grpc/libs/opt/pkgconfig/grpc++_unsecure.pc
So it creates pkgconfig files for "libgrpc++*" libraries, but doesn't create these libraries.
And these having libgrpc++
libgrpc++ depbase=`echo google/protobuf/io/tokenizer.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
and
libgrpc++ depbase=`echo google/protobuf/util/delimited_message_util.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
only two lines
It looks like you only ran make from the third_party/protobuf directory (which you need to do as the first step), and ran make from the helloworld directory. If you did not do so already, you should run make from the grpc repository root directory, per the documentation. This will ensure the libgrpc++* C++ libraries are built.
So, I resolved this problem.
When I run "make" on root gRPC folder, compilation ended with such result:
[CXX] Compiling /home/user/cpp_test/grps/grpc/gens/src/proto/grpc/core/stats.pb.cc
/home/user/cpp_test/grps/grpc/gens/src/proto/grpc/core/stats.pb.cc:187:13: error: ‘dynamic_init_dummy_src_2fproto_2fgrpc_2fcore_2fstats_2eproto’ defined but not used [-Werror=unused-variable]
static bool dynamic_init_dummy_src_2fproto_2fgrpc_2fcore_2fstats_2eproto = []()
^
cc1plus: all warnings being treated as errors
Makefile:2924: recipe for target '/home/user/cpp_test/grps/grpc/objs/opt//home/user/cpp_test/august/grpc/gens/src/proto/grpc/core/stats.pb.o' failed
make: *** [/home/user/cpp_test/grps/grpc/objs/opt//home/user/cpp_test/august/grpc/gens/src/proto/grpc/core/stats.pb.o] Error 1
Because all warnings were treated as errors. And compiling of another libraries was stopped. So I manually added in Makefile in root gRPC directory flag -Wno-unused-variableat the end of 357 line. After adding this flag building of gRPC library went succesfully, and all libgrpc++* and libgrpc* libraries were built.
CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated -Wno-unused-variable

libswscale/swscale.h: No such file or directory

When installing Sumo-0.30.0 on Ubuntu 16.04, make resulted in the following error:
make[4]: Entering directory '/home/<path>/sumo-0.30.0/src/gui'
g++ -DHAVE_CONFIG_H -I. -I../../src -I/home/<path>/sumo-0.30.0/./src -I/usr/include/ffmpeg -I/usr/local/include -I/usr/include/fox-1.6 -I/usr/include/gdal -I/usr/local/include -I/usr/include -msse2 -mfpmath=sse -O2 -DNDEBUG -MT GUIViewTraffic.o -MD -MP -MF .deps/GUIViewTraffic.Tpo -c -o GUIViewTraffic.o GUIViewTraffic.cpp
In file included from GUIViewTraffic.cpp:36:0:
../../src/utils/gui/div/GUIVideoEncoder.h:58:32: fatal error: libswscale/swscale.h: No such file or directory
compilation terminated.
Makefile:449: recipe for target 'GUIViewTraffic.o' failed
Having installed all the prerequisite libraries as mentioned in Installing/Linux Build Libraries and verifying my ffmpeg version is the latest one, I proceeded with ./configure command from installation guide which was successful. The last lines of ./configure result shows that ffmpeg is enabled.
Optional features summary
-------------------------
Enabled: TRACI PROJ GDAL GUI ffmpeg
Disabled: Debug Profiling Coverage PIC UnitTests Python OSG
I could neither locate libswscale directory nor swscale.h even after going through similar post here.
According to another post here, someone mentions that on Ubuntu the problem is that ffmpeg package does not install swscale.h.
How do I fix this?
Install the libswscale-dev package. It provides /usr/include/*/libswscale/swscale.h.

How to use Clang's CUDA compiler?

I am on Ubuntu 17.10. I installed the CUDA 9.1 SDK from NVIDIA.
This is what I tried:
~/GrinGoldMiner/src/Cudacka$ clang++-5.0 -Wl,--cuda-path=/usr/local/cuda-9.1 kernel.cu
clang: error: cannot find libdevice for sm_20. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice.
clang: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes.
clang: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes.
Obviously it doesn't work. It seems like the linker flags are not getting passed. How can I pass them correctly?
It seems clang++-5.0 does not support CUDA 9.X ...
clang++ is able to compile CUDA kernels with CUDA 8.0:
$ clang++-5.0 -O0 -g --cuda-gpu-arch=sm_50 --cuda-path=/usr/local/cuda-8.0 -o t1 t1.cu -L/usr/local/cuda-8.0/lib64 -lcudart
But when using CUDA 9.X I get the same error as you:
$ clang++-5.0 --cuda-gpu-arch=sm_50 --cuda-path=/usr/local/cuda-9.0 -o t1 t1.cu -L/usr/local/cuda-9.0/lib64 -lcudart
clang: error: cannot find libdevice for sm_50. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice.
They added support for Volta (sm_70) and CUDA 9.0 in this commit: 6d4cb40.
In 2017, this was only available on master branch, and you would have confirmed it like this:
$ git clone https://github.com/llvm-mirror/clang.git
$ cd clang/
$ git branch --contains 6d4cb40
* master
$ git checkout release_50
Branch release_50 set up to track remote branch release_50 from origin.
Switched to a new branch 'release_50'
$ git log | grep 6d4cb40
$ (output was empty)
Note that clang (7.0.0, released September 2018) supports CUDA 7.0 through 9.2.
I tried to build the GrinGoldMiner's Cudacka under Ubuntu 17.10, and all I had to do was:
make
This generated two commands on my machine (after some cleanup):
/usr/local/cuda-9.1/bin/nvcc -ccbin g++ -m64 -Xcompiler -fpermissive -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_70,code=compute_70 -o cudacka.o -c kernel.cu
/usr/local/cuda-9.1/bin/nvcc -ccbin g++ -m64 -Xcompiler -fpermissive -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_70,code=compute_70 -o Cudacka.exe cudacka.o
And they finished successfully generating executable Cudacka.exe.
If you are interested specifically in clang:
When I tried to replace g++ with clang++-5.0, I got this error:
nvcc fatal : The version ('50000') of the host compiler ('clang') is not supported
If I use -std=c++11 -ccbin clang++ instead of -ccbin g++, I get this error:
kernel.cu(397): error: explicit instantiation definition directive for __global__ functions with clang host compiler is not yet supported
So, I doubt that you can use clang to compile that code for Ubuntu.

gem install unf_ext -v '0.0.6' fails on Mountain Lion mac

This is the error I get when I run bundle install
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/sam/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby extconf.rb
checking for main() in -lstdc++... yes
checking for ruby/encoding.h... no
creating Makefile
CXX is automatically set to g++-4.6
make
g++-4.6 -I. -I/opt/local/include -I. -I/Users/sam/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/i686-darwin12.5.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -O2 -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -fno-common -pipe -fno-common -c unf.cc
make: g++-4.6: No such file or directory
make: *** [unf.o] Error 1
Gem files will remain installed in /Users/sam/.rvm/gems/ree-1.8.7-2012.02#global/gems/unf_ext-0.0.6 for inspection.
Results logged to /Users/sam/.rvm/gems/ree-1.8.7-2012.02#global/gems/unf_ext-0.0.6/ext/unf_ext/gem_make.out
An error occurred while installing unf_ext (0.0.6), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.6'` succeeds before bundling.
It looks like g++ 4.6 is missing.
which g++ returns /usr/bin/g++ but which g++-4.6 returns nothing.
I definitely have Xcode Developer Tools installed. I'm not really sure what to do. How can I get bundle install to succeed?
Installed fine using jruby. Seems to be a problem with the ree version I was using.