Skip to content

document: Instead of adding cl.exe in PATH, use a more convenient way #79

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

Closed
Puiching-Memory opened this issue Mar 9, 2025 · 2 comments

Comments

@Puiching-Memory
Copy link

https://vscode.js.cn/docs/cpp/config-msvc#_run-vs-code-outside-the-developer-command-prompt

If you have Visual Studio installed, you may notice two new terminals:
Developer PowerShell for VS 2022
Developer Command Prompt for VS 2022

Running cl in it will take effect without manually adding cl.exe to PATH.
The difference between them and normal shells is that automatic configuration of environment variables is performed before startup.

You can find them in the installation path:
"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1"
"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\LaunchDevCmd.bat"

If we want to use cl in any terminal, we can simply run them in advance.

& "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1"
**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.13.2
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************

PS C:\> cl
用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.43.34808 版
版权所有(C) Microsoft Corporation。保留所有权利。

用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]

PS C:\> & C:/python.exe c:/triton_windows.py                       
cuda_utils.c
  正在创建库 C:\Users\11386\AppData\Local\Temp\tmpjjs4bbey\cuda_utils.cp312-win_amd64.lib 和对象 C:\Users\11386\AppData\Local\Temp\tmpjjs4bbey\cuda_utils.cp312-win_amd64.exp
ptxas info    : 0 bytes gmem
ptxas info    : Compiling entry function 'add_kernel' for 'sm_89'
ptxas info    : Function properties for add_kernel
    0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info    : Used 26 registers, used 0 barriers, 380 bytes cmem[0]
ptxas info    : Compile time = 0.000 ms
__triton_launcher.c
  正在创建库 C:\Users\11386\AppData\Local\Temp\tmp15uy06sv\__triton_launcher.cp312-win_amd64.lib 和对象 C:\Users\11386\AppData\Local\Temp\tmp15uy06sv\__triton_launcher.cp312-win_amd64.exp
tensor([0., 0., 0.], device='cuda:0')
If you see tensor([0., 0., 0.], device='cuda:0'), then it works
@woct0rdho
Copy link
Owner

Thank you for the suggestion. I've added this to the README. However, the user still needs to make sure what environment they're in.

@woct0rdho
Copy link
Owner

There is another caveat: Launch-VsDevShell.ps1 or LaunchDevCmd.bat loads x86 rather than x64 tools by default, which may cause problems.

You can run Launch-VsDevShell.ps1 -Arch arm64 or VsDevCmd.bat -arch=amd64 or 'x64 Native Tools Command Prompt' (vcvars64.bat) to load x64 tools.

Unfortunately, there is no shortcut to open PowerShell with x64 tools by default, and you cannot pass -arch=amd64 to LaunchDevCmd.bat, as of VS 2022.

See https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell

For reference, vcvars64.bat is a wrapper of vcvarsall.bat, and vcvarsall.bat is a wrapper of VsDevCmd.bat. LaunchDevCmd.bat is also a wrapper of VsDevCmd.bat.

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