在Atom中使用platform-ide-terminal构建CUDA

问题描述 投票:0回答:2

我希望能够使用Windows 10 Powershell编译和构建here提供的CUDA C源代码。使用x 64 Native Tools Command Prompt for VS 2017执行此操作没有问题。

但是,我尝试了几种在线建议的方法来使Powershell正常工作,但没有成功。原因是我希望能够使用其程序包platformio-ide-terminal在Atom(编辑器)中构建自己的cuda代码,该程序包在Atom中加载Powershell。因此,如果我弄清楚了如何在Powershell中设置Visual Studio 2017社区,则可以在Atom中编辑代码并使用其Powershell集成方便地构建它们。

我尝试如下设置环境,但是platformio-ide-terminal仍然找不到nvcc的路径。

有人可以帮我吗?

cl.exe
visual-studio powershell cuda nvcc cl
2个回答
2
投票

您可以将cl.exe的路径添加到环境变量中:

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\Users\AFP\Downloads\cuda_by_example> cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\" PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build> .\vcvarsall.bat amd64 ********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.7.3 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build> cd C:\Users\AFP\Downloads\cuda_by_example\ PS C:\Users\AFP\Downloads\cuda_by_example> nvcc .\chapter03\hello_world.cu nvcc fatal : Cannot find compiler 'cl.exe' in PATH PS C:\Users\AFP\Downloads\cuda_by_example>

然后添加control panel > view advanced system settings > Environment variables > Path > New

或使用此命令进行编译:C:\Program Files (x86)\Microsoft Visual Studio\<year >\Community\VC\Tools\MSVC\<toolset>\bin\Hostx64\x64


0
投票

打开Windows Powershell并在提示符下运行以下命令:

nvcc x.cu .\chapter03\hello_world.cu  -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\<year >\Community\VC\Tools\MSVC\<toolset>\bin\Hostx64\x64"

自动化

要自动执行此操作,请创建一个名为Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\Users\AFP\Downloads\cuda_by_example> & 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat' amd64 ********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.7.3 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' PS C:\Users\AFP\Downloads\cuda_by_example> $ENV:PATH="$ENV:PATH;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\Hostx64\x64" PS C:\Users\AFP\Downloads\cuda_by_example> nvcc .\chapter03\hello_world.cu hello_world.cu Creating library a.lib and object a.exp PS C:\Users\falah\Downloads\cuda_by_example> .\a.exe Hello, World! PS C:\Users\falah\Downloads\cuda_by_example> 的文件,并将以下两个命令放入其中。

nvcc_setup_for_powershell.ps1

& 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat' amd64 $ENV:PATH="$ENV:PATH;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\Hostx64\x64" 下的platformio-ide-terminal的打开设置将放置PowerShell脚本的路径:Core > Run Command

& "C:\Path\To\Script\nvcc_setup_for_powershell.ps1"您可能需要以管理员身份打开PowerShell并运行以下命令]

enter image description here

允许您执行Set-ExecutionPolicy RemoteSigned

© www.soinside.com 2019 - 2024. All rights reserved.