RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorCopy.cpp:20

I’ve a numpy array that I’m trying to load into a pytorch tensor, it’s loaded properly on cpu device but on cuda device it fails with following error;

>> torch.tensor(X_train, dtype=torch.float64, device=cuda)
RuntimeError                              Traceback (most recent call last)
<ipython-input-92-4ee38d4004b1> in <module>()
----> 1 torch.tensor(X_train, dtype=torch.float64, device=cuda)

RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorCopy.cpp:20

I tried to load the numpy array into a pandas DataFrame to have a look at it but nothing seems suspecious:

>> pd.DataFrame(X_train).describe()

0	1	2	3	4	5	6	7	8	9	...	560	561	562	563	564	565	566	567	568	569
count	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	...	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000	30.000000
mean	-0.611895	-0.610648	-0.606697	-0.601020	-0.593792	-0.585476	-0.577100	-0.568880	-0.561298	-0.555327	...	-0.976487	-0.977011	-0.977404	-0.977851	-0.978500	-0.979447	-0.979884	-0.979993	-0.980466	-0.980602
std	0.007103	0.007094	0.007025	0.006931	0.007014	0.007098	0.007005	0.006994	0.007035	0.007000	...	0.006211	0.006145	0.006196	0.006212	0.006270	0.006313	0.006392	0.006372	0.006364	0.006407
min	-0.622784	-0.622222	-0.619049	-0.613251	-0.606484	-0.598921	-0.590348	-0.582025	-0.574668	-0.568545	...	-0.995849	-0.996575	-0.997365	-0.997696	-0.998277	-0.999678	-1.000187	-1.000031	-1.000642	-1.001061
25%	-0.615420	-0.614054	-0.609959	-0.604032	-0.596716	-0.588481	-0.579605	-0.571327	-0.563762	-0.557526	...	-0.978997	-0.979154	-0.979423	-0.979826	-0.980450	-0.981289	-0.982201	-0.982305	-0.982654	-0.982617
50%	-0.611913	-0.610543	-0.606757	-0.601161	-0.593762	-0.585272	-0.577268	-0.569677	-0.561556	-0.555934	...	-0.975869	-0.976176	-0.976744	-0.977298	-0.977871	-0.978881	-0.979175	-0.979325	-0.979627	-0.980093
75%	-0.609884	-0.608681	-0.604591	-0.599247	-0.591120	-0.582454	-0.574215	-0.565808	-0.558239	-0.551438	...	-0.972170	-0.973330	-0.973860	-0.974376	-0.974811	-0.975666	-0.976206	-0.976166	-0.976381	-0.976528
max	-0.590921	-0.589520	-0.586062	-0.582049	-0.575003	-0.566571	-0.559088	-0.551611	-0.544998	-0.539241	...	-0.968274	-0.968620	-0.968871	-0.969230	-0.970103	-0.971065	-0.971451	-0.971528	-0.971549	-0.971597
8 rows × 570 columns

What could be the reason of this error?

Could you try to use torch.from_numpy and run it again?

1 Like

Sorry for the late reply @ptrblck this is no more applicable. In fact after resetting my notebook I am now able to load the numpy array.