andreinechaev / nvcc4jupyter

A plugin for Jupyter Notebook to run CUDA C/C++ code
MIT License
200 stars 87 forks source link

%%cuda -n <name> does not work #11

Closed yaridor closed 9 months ago

yaridor commented 3 years ago

Hello,

Your examples in https://www.geeksforgeeks.org/how-to-run-cuda-c-c-on-jupyter-notebook-in-google-colaboratory/ works OK. Then I tried:

%%cuda -n drive/MyDrive/cuda1.cu (cuda1.cu includes the code of your of "maximum element from vector ". I mounted my good drive which includes cuda1.cu. But I get UsageError: %%cuda is a cell magic, but the cell body is empty.

what am I doing wrong ?

Thanks in advance,

andreinechaev commented 3 years ago

Hello, Just to be clear, it is not my post. The original post was on Medium https://medium.com/@iphoenix179/running-cuda-c-c-in-jupyter-or-how-to-run-nvcc-in-google-colab-663d33f53772 Even more interesting that you use the 2nd version of the plugin. The cell command you use - %%cuda -n ... - Creates a file with the given name. If I understand correctly, you want to load an external file from your Google Drive. It is an interesting use case, I can look into it. To resolve your issue I'd recommend to either copy your code into the cell. Or as another option copy your cuda source file into the home directory and then run a cell with

%%cuda_run
# This line just to bypass an exeption and can contain any text
yaridor commented 3 years ago

Hello,

If I understand correctly, you want to load an external file from your Google Drive. It is an interesting use case, I can look into it.

Yes. This is exactly what I want to do. thanks for considering this option

To resolve your issue I'd recommend to either copy your code into the cell. Or as another option copy your cuda source file into the home directory and then run a cell with %%cuda_run

I am still not sure how to use "cuda_run" with my Cuda file in my home directory. do you have an example of using cuda_run ?

andreinechaev commented 2 years ago

cuda_run will take all cuda files in your home dir and will compile and run them. use it as in the initial comment. Just will an empty cell with exactly this

%%cuda_run
# This line just to bypass an exeption and can contain any text