Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThrustRTC example failed execution - Loading libnvrtc failed. cuMemAlloc() failed with Error code: 2 #14

Closed
r4d10n opened this issue Jun 21, 2021 · 5 comments

Comments

@r4d10n
Copy link

r4d10n commented Jun 21, 2021

image

I have a working CUDA 11.3 environment with GTX-1660Ti, Thrust library also tested working.

I installed ThrustRTC-0.3.11 with pip and tried to execute the example code given on the github page. It fails with the above message. Any suggestions/fixes ??

@r4d10n
Copy link
Author

r4d10n commented Jun 21, 2021

On my Manjaro Linux installation, I had to manually link /usr/local/cuda to /opt/cuda to get it almost working (Some examples seems to fail).

$ sudo ln -s /opt/cuda /usr/local/cuda

How can I specify the search path for libnvrtc in Windows ?

@r4d10n
Copy link
Author

r4d10n commented Jun 21, 2021

For the basic ReplaceIf example, I am getting this error in Manjaro Linux:

 header_of_structs.h:
1	struct _S_fde307d2fa10b8c1
2	{
3	    typedef _S_fde307d2fa10b8c1 CurType;
4	    VectorView<int32_t> view_vec;
5	    int32_t pred;
6	    int32_t new_value;
7	    template<class _T0>
8	    __device__ inline auto operator()(const _T0& idx)
9	    {
10	    if (pred(view_vec[idx])) view_vec[idx] = (decltype(view_vec)::value_t)new_value;
11	    }
12	};
13	

saxpy.cu:
1	#define DEVICE_ONLY
2	#include "cstdint"
3	#include "cfloat"
4	#include "built_in.h"
5	#include "header_of_structs.h"
6	
7	extern "C" __global__
8	void saxpy(size_t n, _S_fde307d2fa10b8c1 func)
9	{
10	    size_t tid =  threadIdx.x + blockIdx.x*blockDim.x;
11	    if(tid>=n) return;
12	    func(tid);
13	
14	}
15	

Errors:
header_of_structs.h(10): error: expression preceding parentheses of apparent call must have (pointer-to-) function type

1 error detected in the compilation of "saxpy.cu".

Traceback (most recent call last):
  File "/home/rax/exp/gpu/thrust/test-thrust.py", line 4, in <module>
    trtc.Replace_If(A, trtc.DVInt32(1), trtc.DVInt32(99))
  File "/home/rax/.local/lib/python3.9/site-packages/ThrustRTC/Transformations.py", line 10, in Replace_If
    check_i(native.n_replace_if(vec.m_cptr, pred.m_cptr, new_value.m_cptr))
  File "/home/rax/.local/lib/python3.9/site-packages/ThrustRTC/Native.py", line 16, in check_i
    raise SystemError("An internal error happend")

Histogram and K-Means examples are running fine.

@fynv
Copy link
Owner

fynv commented Jun 23, 2021

For the first question, trtc.set_libnvrtc_path() can be used to set the location of the libnvrtc.so or nvrtc64*.dll. You need to call it immediately after "import ThrustRTC as trtc", and give the full path to the shared library.

For the second question, the error is because trtc.Replace_If() is expecting a trtc.Functor as its 2nd parameter. See https://github.com/fynv/ThrustRTC/blob/master/python/test/test_replace.py for detail.

@r4d10n
Copy link
Author

r4d10n commented Jun 25, 2021

Hi Fei..

  1. Adding this after import fixed it for me in Windows !
    trtc.set_libnvrtc_path("C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\bin\nvrtc64_112_0.dll")

  2. I guess the example in the README.MD has to be updated to trtc.Replace() - which works fine ! Thanks for the excellent example...

This environment does indeed make GPU computing far more easier !

Cheers...

@r4d10n r4d10n closed this as completed Jun 25, 2021
@fynv
Copy link
Owner

fynv commented Jun 26, 2021

Ah yes, sorry for the readme mistake. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants