【问题标题】:Run a cuda file using terminal / IDE使用终端/IDE 运行 cuda 文件
【发布时间】:2021-09-20 21:05:54
【问题描述】:

我有一个要运行和编译的 test.cu cuda 文件。 以下是我尝试过的事情。

  1. 在 sublime-text 4 中构建 cuda 构建系统
{
    "shell_cmd": "nvcc $file_name -o ${file_base_name} && ${file_path}/${file_base_name}",
    "working_dir": "$file_path",
    "selector": "source.cu, source.lib, source.exp",
    "path": "/usr/lib/nvidia-cuda-toolkit/bin",
    "shell": true
}

但是,使用上述系统编译 test.cu 后。我得到了

/usr/bin/env: ‘bash’: No such file or directory
[Finished in 6ms with exit code 127]
[shell_cmd: nvcc test.cu -o test && /home/name/My Data/Code Repo/Geometric Learning/test]
[dir: /home/name/My Data/Code Repo/Geometric Learning]
[path: /home/name/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
  1. 使用终端编译
nvcc test.cu -o test

生成a.outtest。 在这之后我跑了

test

什么也没返回。

如何编译和运行代码(最好是 sublime 文本)?

系统规格:nvcc 10.1 + ubuntu 20.04 操作系统。

【问题讨论】:

    标签: cuda gpu sublimetext3 nvcc


    【解决方案1】:

    以下是编译.cu文件的方法

    1. 终端
    $ nvcc test.cu 
    $ ./a.out
    
    1. 崇高的构建系统
    {
        "shell_cmd": "nvcc \"${file_path}/${file_name}\" && ./a.out && rm a.out",
        "working_dir": "$file_path",
        "selector": "source.cu, source.lib, source.exp",
        "shell": true
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-19
      • 1970-01-01
      • 2018-07-09
      • 2019-09-15
      • 2018-09-10
      • 2011-09-26
      • 2019-09-17
      • 2017-09-07
      相关资源
      最近更新 更多