Closed MaximeRoux closed 5 years ago
Can you provide a minimal example that shows this issue when compiled?
This one for example :
#include <stdio.h>
#include <stdexcept>
#include <iostream>
#define VEXCL_BACKEND_CUDA
#include <vexcl/vexcl.hpp>
int main(void)
{
vex::Context ctx(vex::Filter::GPU);
if (!ctx) throw std::runtime_error("No devices available.");
// Print out list of selected devices:
std::cout << ctx << std::endl;
return 0;
}
I am sorry, I don't have Windows or Visual Studio, and I can not reproduce the issue with boost 1.69 and cuda 10.0.130 on my linux machine.
Using either this CMakeLists.txt
:
cmake_minimum_required(VERSION 3.11)
project(hello)
find_package(VexCL)
add_executable(hello hello.cpp)
target_link_libraries(hello VexCL::CUDA)
or this command line:
g++ -o hello hello.cpp -I ~/work/vexcl -I /opt/cuda/include/ -lcuda
yields no compilation errors here.
I compile with nvcc because the compiler (msvc) doesn't recognize any CUDA functions or macro.
VexCL CUDA backend uses driver API (as opposed to runtime API supported by nvcc), so you don't need to compile the code with nvcc. Can you try to compile it with cl.exe instead?
You mind compiling it using the OpenCL backend instead of the CUDA backend ?
It works with OpenCL as well as with CUDA backend for me, replacing VEXCL_BACKEND_CUDA
with VEXCL_BACKEND_OPENCL
in your example, and using
g++ -o hello hello.cpp -I ~/work/vexcl -lOpenCL
For me It works for VEXCL_BACKEND_COMPUTE
and VEXCL_BACKEND_COMPUTE
but not for VEXCL_BACKEND_CUDA
Excuse me for my last comment I wanted to say : You mean compiling it using the OpenCL backend instead of the CUDA backend when you said "Can you try to compile it with cl.exe instead? "
No, I meant that you should treat the project as normal (non-cuda) C++ project. No need to involve nvcc at all. nvcc is only used at run-time to compile the generated kernels. Your program is compiled with host compiler (cl.exe
in case of the visual studio, or g++
/clang++
on linux) and is linked against cuda.lib
/libcuda.so
.
I treat the project as normal now (as a C++ project), I had already linked cuda.lib but I still have the same issue than before, msvc doesn't recognize any CUDA functions or macro (like CUDA_SUCCESS for example).
Is it possible MSVC does not know how to include <cuda.h>
and you just need to set the correct include path for the project? A simple test would be a successful compilation of
#include <iostream>
#include <cuda.h>
int main() {
std::cout << CUDA_SUCCESS << std::endl;
}
I resolved the problem my compiler took the cuda.h
of boost... But now I have the same error than before with nvcc which is :
1>C:\Utils\vexcl-master\vexcl/backend/cuda/texture_object.hpp(41): error : explicit specialization of class "vex::traits::is_vector_expr_terminal<size_t, void>" must precede its first use ( line 20 of C:\Utils\boost_1_69_0\boost\mpl\aux_\has_type.h )
The error is different now (it references C:\Utils\boost_1_69_0\boost\mpl\aux_\has_type.h
instead of C:\Utils\vexcl-master\vexcl\backend\cuda\texture_object.hpp
) and I am still not able to reproduce this. I think there is probably another issue with your project configuration.
Are you able to configure and compile vexcl examples/tests with cmake (cmake will generate a visual studio solution for you)? And after that, try to use the cmake I pasted above with your own example.
But to use your makefile I need the file FindVexcl.cmake
It will be available once you configure vexcl (it registers itself in cmake local packages).
What did you mean by "configure vexcl "?
Something like this:
cd C:\Utils\vexcl-master\
mkdir build
cd build
cmake ..
or an equivalent with cmake GUI.
I did that with cmake GUI, the configuaration and generation worked but still no FindVexcl.cmake.
I don't think I tried this on Windows. Another option would be to add vexcl as a subfolder to your project and replace find_package (VexCL)
with add_subdirectory(vexcl)
in your CMakeLists.txt
.
Thanks, finally it found the package. But even with the cmake I still have the same problem with is_vector_expr_terminal
Sorry, I have no other ideas besides may be try newer version of visual studio.
No problem, thanks for your help
I tried to compile the examples of vexcl as you said before but I have many errors like this one
CMake Error at CMakeLists.txt:10 (add_executable): Target "complex_spmv" links to target "VexCL::Backend" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? Call Stack (most recent call first): CMakeLists.txt:27 (add_vexcl_examples)
What value of VEXCL_BACKEND
cmake variable you used? The error looks like vexcl cmake was not able to find the selected backend. It is possible you need to help cmake by providing paths to include/library folders. If you show all settings in cmake gui, (check advanced):
you should be able to see if there are any OpenCL/CUDA-related settings with undefined values.
I compile this way
"Where is the source code" field should point to the vexcl root (vexcl-master
).
Yes this one works
You also need to check "VEXCL_BUILD_EXAMPLES" and/or "VEXCL_BUILD_TESTS" to actually try compiling anything. And set "VEXCL_BACKEND" to "CUDA".
Yes thanks I found these options, the configuration is working well but not the generation I have the following error :
I removed the part Thrust interoperation examples of the cmake so now it is well generated and we can see at compilation that I have the same error as before :
These errors are different from what you got initially and actually make some sense now. These say that template specializations for cl_ulong and _int64_t
have been declared twice. I suspect the reason is that CUtexObject
on Windows is actually typedef
'ed as _uint64_t
and the errors come from these specializations:
Can you try to comment out these lines and see if your examples compile? It should be safe to comment out lines 40-42.
Unfortunately, if CUtexObject
is indeed just _uint64_t
on windows, then there is no way to use texture objects after commenting lines 44-46.
When I comment the lines 40 to 46 I have the following errors :
These look like cmake errors, not compiler ones.
Yes but I didn't change the cmake, maybe I have to remove texture_object.hpp
I would just try to reconfigure cmake first (that is, remove everything from the build directory and run the cmake-gui again).
Finally it works I had a problem with the file cmake.exe, thanks for your help
Thank you for rising this! Do you mind if we try to solve the issue with CUtexObject
before we close this? I think I know how to solve this, but I would need your help testing if the solution actually works.
Could you please see if #270 works for you and that tests/image.exe
works with the CUDA backend?
So, I have to modify texture_object.hpp
?
You can just download the updated code from #270 at https://github.com/ddemidov/vexcl/archive/issue-269.zip.
Compilation for image works well but not the runtime I have this :
seed: 1553172225
1. GeForce GTX 1050 Ti
2. GeForce GTX 1050 Ti
Running 2 test cases...
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned long long ulong;
extern "C" __global__ void vexcl_vector_kernel
(
ulong n,
float * prm_1,
int prm_2
)
{
for
(
ulong idx = blockDim.x * blockIdx.x + threadIdx.x, grid_size = blockDim.x * gridDim.x;
idx < n;
idx += grid_size
)
{
prm_1[idx] = prm_2;
}
}
unknown location(0): fatal error: in "cr/image1d": class std::runtime_error: nvcc invocation failed
C:\Utils\vexcl-issue-269\tests\image.cpp(10): last checkpoint: "image1d" test entry
*** 1 failure is detected in the test module "Image"
C:\Utils\vexcl-master\build\build\tests\Debug\image.exe (process 21912) exited with code 201.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
The runtime can not find cl.exe
which is the visual studio compiler. I think you need to either add the location of cl.exe
to PATH
environment variable, or (easier) run the tests from the visual studio command prompt (it used to be in the Start menu under Visual studio/tools).
Yes it seems to be working
seed: 1553175864
1. GeForce GTX 1050 Ti
2. GeForce GTX 1050 Ti
Running 2 test cases...
kernel.cu
kernel.cu
kernel.cu
*** No errors detected
Thanks again for testing!
Hello, I want to use the cuda backend of vexcl but it doesn't work I have the following error :
Error explicit specialization of class "vex::traits::is_vector_expr_terminal<size_t, void>" must precede its first use C:\Utils\vexcl-master\vexcl\backend\cuda\texture_object.hpp 41
I have boost 1.69, visual studio 2017 15.9.7 and cuda 10. Maybe my boost version is too recent ?