How do I run nvidia-smi on Windows? - windows

nvidia-smi executed in a Command Prompt (CMD) in Windows returns the following error
C:\Users>nvidia-smi
'nvidia-smi' is not recognized as an internal or external command,
operable program or batch file.
Where is it located? CUDA is installed already.

Nvidia-SMI is stored by default in the following location
C:\Windows\System32\DriverStore\FileRepository\nvdm*\nvidia-smi.exe
Where nvdm* is a directory that starts with nvdm and has an unknown number of characters after it.
Note: Older installs may have it in C:\Program Files\NVIDIA Corporation\NVSMI
You can move to that directory and then run nvidia-smi from there. However, the command prompt window will not persist, making it very difficult to see the information. Additionally it is challenging to determine what the nvdm* directory is as this changes and there are multiple directories of this format. To complicate matters, unlike linux, it can't be executed by the command line in a different path. It's better to find the exact location and create a shortcut that runs it in a periodic manner.
To find your exact location
Open File Explorer (File Folder Icon on your Task Bar, Near Start / Cortana / Task View buttons).
In the left Pane, click 'This PC'.
In the main viewer, just to the top of the Icons, is a search bar. Type nvidia-smi.exe and hit enter. It will come up after some time.
Right-click and choose 'Open File Location' and continue with the below instructions to make a desktop shortcut, or double click to run once (not recommended, as it runs and closes the window once complete, making it hard to see the information).
Make a shortcut that runs nvidia-smi and refreshes periodically
Follow the above steps under 'To find your exact location'.
Right click on nvidia-smi.exe (it may just say nvidia-smi in the viewpane) and choose create a shortcut. It will likely tell you that you can't create a shortcut here, and ask if you want to put it on your desktop. Hit yes.
Now, on the desktop, right click on the shortcut you have just created, hit properties, and Under Shortcut > Target modify the string path to include -l < time you want it to refresh >.
For example, modify:
C:\Windows\System32\DriverStore\FileRepository\nvdm*\nvidia-smi.exe
to
C:\Windows\System32\DriverStore\FileRepository\nvdm*\nvidia-smi.exe -l 5
Then hit "Apply", and then "OK".
In this example, when you open the shortcut, it will keep the command prompt open and allow you to watch your work as nvidia-smi refreshes every five seconds.

You can add "C:\Program Files\NVIDIA Corporation\NVSMI" to PATH and than restart console.
System Properties > Advanced > Environment Variables > System Variables -> Path -> Edit > New > insert folder path with nvidia-smi

On my Windows 10 machine installed with CUDA 10.2, nvidia-smi.exe can be found at C:\Windows\System32.
Because C:\Windows\System32 is already in the windows PATH, running nvidia-smi in command prompt should now work out of the box

Go to the file explore then go to the C drive in the search bar type nvidia-smi
Wait sometimes when exe file is open right click go to the properties copy the location path
Then go to the anaconda command prompt change the working directory by using the copy path in step 2
Then write "nvidia-smi" hit enter
Click Here for more information

On Windows, you can use the Power Shell and type nvidia-smi -l 1 to GPU summary every 1 second, or nvidia-smi -lms every millisecond. Don't forget to add the CUDA environment files to PATH, as mentioned in the above suggestions.

You can try to write a .bat file for a one-click operation later.
ECHO Open folder
::my nvidia-smi folder (nvidia-smi.exe can be found on two different folders, either is ok)
cd /d c:\Program Files\NVIDIA Corporation\NVSMI
::cd /d c:\Windows\System32\DriverStore\FileRepository\nvami.inf_amd64_42b7e5f6a9e28f81
ECHO NVIDIA-SMI
::use `-l < time you want it to refresh >` to keep window
call nvidia-smi.exe -l 3
reference to #Hewston, the aforementioned script can be further simplified as follows:
::ECHO Open folder
::add my nvidia-smi folder to PATH variable
::cd /d c:\Program Files\NVIDIA Corporation\NVSMI
ECHO NVIDIA-SMI
::use `-l < time you want it to refresh >` to keep window
call nvidia-smi.exe -l 5

Related

How can I open command prompt in the current directory as a shortcut

I'm just wondering how I can make a shortcut that will open command prompt in the folder it is currently in.
Why I need this.
I save my c program file in the directory Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\
So I would have to type cd Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\ every time I want to open the command prompt in that directory.
Is there a shortcut I can make where I can move that shortcut around anywhere (don't need to change the shortcut) and it will open command prompt in the directory it is current in, so I don't need to keep typing cd .....
you can go to the directory and just type start . in the same directory
or you can make a batch file like test.bat and add below line in the same:
cd Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\
Save it anywhere and whenever you will run that batchfile, it will automatically move PWD to the required directory
Right-click in the open space of your desktop and click New > Shortcut
For the location, type or copy and paste one of the following lines.
%windir%\system32\cmd.exe /k cd Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\
As commented by aschipfl, you can already do it, (may be OS dependent)!
In Windows Explorer, or I suppose the desktop, just hold down the shift key, right click in a blank area of it and choose Open command window here, (or whatever your locale states).
I think in Windows 10 at least, the option is even available in the Explorer toolbar menu too.

Executing a command-line .exe file

I have a .exe file converted from a .jar.
It is a command based application, so I have to start it with a batch script. Here is the batch script:
#echo off
cd C:\desktop\plant-text-adventure-win
start planttextadventure
pause
When I double click on the batch script, this happens: Windows could not find 'planttextadventure'. Please confirm if you have input the correct name and retry.
I don't know what is happening, I have no idea about cmd as I use Mac, but I can confirm I have an executable called planttextadventure.exe in a folder called plant-text-adventure-win.
You should test your batch file by executing it within a shell.
Simply enter within the start menu the command cmd to open up a shell. Within this black box you could now simply enter the commands from your batch script and lookout for some error message.
If you look at your script I would guess that the cd command (to change the current directory) is not correct. Maybe you should replace it with
cd %USERPROFILE%\Desktop\plant-text-adventure-win
because the desktop folder is on a default installation not directly under the root drive but within the user profile available.
Another solution to get this thing to work, is by opening the windows explorer, going to the .exe file you wish to execute and drag & drop the .exe file with a right mouse click onto the desktop.
Then a context menu appears and you select the option Create shortcut here.

Open Multiple Instances of an App from File Explorer

Short version:
On Windows, if I select several .txt files in a File Explorer and then right click on one of the selected files and choose "Open" from the popup menu, all of the selected files will be opened, each in a separate instance of Notepad.
I want the same behavior for our files/editor: select multiple output files, right click one, select Open: -> all files are opened, each in their own instance of our editor.
I have basic click-to-open working (for a single file, double click opens the file in our editor, right click and Open does the same).
Details
We have an launcher (FuBarStudioLauncher.exe) that updates then launches our editor tool (FuBarStudio.exe), which produces resource files with a custom extension (samplefile.fbr)
If you run from the command line, you can fire up the editor, opening a particular resource:
C:\path_to_my_exe\FuBarStudio.exe" -ide samplefile.fbr
I have a windows registry entry set up so that when I double click on a *.fbr resource file, or right-click and select Open from the popup menu, the launcher runs, passing the given resource through to the editor.
The relevant registry entries:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.fbr]
#="FuBar.Place"
[HKEY_CLASSES_ROOT\.fbr\FuBar.Place]
[HKEY_CLASSES_ROOT\.fbr\FuBar.Place\ShellNew]
and
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\FuBar.Place]
#="FuBar Place"
[HKEY_CLASSES_ROOT\FuBar.Place\shell]
[HKEY_CLASSES_ROOT\FuBar.Place\shell\Open]
#="Open"
[HKEY_CLASSES_ROOT\FuBar.Place\shell\Open\command]
#="\"C:\\path_to_my_exe\\FuBarStudioLauncher.exe\" -ide \"%1\""
All of this works fine for single files.
If I select more than one .fbr file and then right click one of the selected files and select "Open", I will only open one instance of FuBar Studio.
I would like to open one Copy of FuBar Studio, one for each file.
So with some help I got a useful answer.
1) I read up on use of MultiSelectModel here:
https://msdn.microsoft.com/en-us/library/windows/desktop/hh127436(v=vs.85).aspx
Set my type to Document.
2) I created a batch script as an intermediary, so I could see better what was going on:
[HKEY_CLASSES_ROOT\FuBar.Place\shell\Open\command]
#="\"C:\\path_to_my_exe\\launcher.bat\" \"%1\""
Toyed around with this script, writing things to tmp files:
echo "interesting things" >> logs.txt
and using timeout to force things to pause/slow down:
timeout 10
Using "echo" and so forth I realized that whether MultiSelectModel is set to Document or Player, when I select multiple files and right click "Open", Windows is executing the business at:
HKEY_CLASSES_ROOT\FuBar.Place\shell\Open\command
once per selected file.
I could not find a way to force Windows to call the command once, passing all the files as arguments to the command.
3) By experimenting with other programs besides my own, and with the script + timeouts giving me a command shell with error spew to look at, I realized that my particular program, FuBarStudioLauncher.exe, always fails if another instance is running.
So here's what I have:
Windows is going to run one instance of <something> per input file.
<something> can't be my FuBarStudioLauncher.exe, because after one is running the next N will fail.
So I need an intermediary script that will do some kind of critical section locking:
- grab lock.
- run launcher to completion.
- release lock.
Hooray for StackOverflow:
Semaphore for CMD instances working in Parallel
Using this as input, my final product:
:lockedAppend
2>nul (
>>%~dp0launcher_script_lockfile.txt (
REM Do any amount of processing within this block.
REM All stdout will safely be appended to the queue
REM You could even call out to a subroutine, or another batch file
%~dp0FuBarStudioLauncher.exe -ide "%1"
REM The CALL below ensures that the block exits with ERRORLEVEL 0 - success
(call )
)
) || goto :lockedAppend
That did it!

How do you run programs in Windows terminal?

What is the windows equivalent to "./filename"
So for example I would usually compile by doing something like:
gcc -c homework1.c
gcc -o homework1 homework1.o
This would give me the executable names homework1
And for me to run the program, I would type: ( ./homework1 ) <-- ignore the parenthesis.
Usually I was write all my code in my schools Unix Shell thingy and I also compile it and run it there, but recently I think I took up all the disc space (because it says "disc quota exceeded").
Run cmd.exe
Go to where the program is example : cd C:\foder1\
Then type the program name with extension, for example : test1.exe or "test1.exe"
In windows (as in Linux) you can either run a program though a GUI interface or from a shell environment.
The GUI option is a program called Explorer, you navigate through the file system and double click executable files to run then. Executable typically have the extension '.exe' or '.bat', but there are others.
The shell environment in windows is called the 'command prompt', you can run it by going to the start menu and selecting 'run' or simply press the windows key and 'r' simultaneously. A box will popup, type 'cmd' (without the quotes) and hit enter - the command prompt should open. From there you can navigate the file system using commands like 'cd'. To run your executable type the name of the file (it should work with or without the '.exe').
A nice shortcut to open the command prompt already at a particular path, is to browse to the folder in Explorer, hold shift and then right-click the folder - the resulting context menu that pops up should have an option like 'open in command prompt'.

Windows CMD: How to create symbolic link to executable file?

My goal is to add a few executables to my PATH (for example, chrome), so that I can call
> chrome
from the command prompt and it will launch Chrome.
I know I could add Chrome's containing directory to my path (set PATH=%PATH%<chrome_path_here>;), but since I have a few executables I want to add, I'd rather make a new bin directory that contains symbolic links to the actual executables and just add that single directory to my PATH.
The Chrome executable is located at
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
So I tried
> mklink chrome.exe "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
That successfully creates a symbolic link for the files (says so in output, and upon examining with > dir). I know my PATH is set up correctly, b/c when I run > where chrome it finds my new symbolic link.
However, when I try to execute chrome with my new link, nothing happens. A new empty window should appear, but nothing happens. No error message in the command prompt or anything.
What am I doing wrong? Am I misunderstanding symlinks in Windows? This is the approach I use in Linux all the time, but I'm new to Windows Cmd.
Thanks!
Most programs will not run from places other than they install location - which is exactly what happens when you try to run it from symlink.
It would be much easier to create CMD/BAT files in that folder with matching names which will launch programs from locations you want:
REM chrome.cmd
start /b cmd /c "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %*
With Windows 7 I confirm that symlinks do not work, are simply ignored as reported in the original question.
As Harry states in his comment, shortcuts do work, and to me are simpler and easier than writing a separate script for each new command I want to enable under CMD.
He states that you need to add .lnk to your PATHEXT variable in order to do this. I affirm that this does work, and with .lnk added to PATHEXT I can simply enter the name portion of the shortcut to run the command. For example if my shortcut is named "sublime.lnk" and PATHEXT includes .lnk, I can execute the link with the simple command "sublime". Nice!
As an alternative I found that PATHEXT need not be modified if I simply type in the full name of the shortcut, including the .lnk, at my CMD prompt. E.g., I created a shortcut named "sublime.lnk" under %HOMEPATH%/bin, pointing to "C:\Program Files\Sublime Text 2\sublime_text.exe".
Now by placing %HOMEPATH%\bin in my %PATH% I can run sublime via the command "sublime.lnk".
Either of the above are the best way I know of giving access to various commands from around Windows' filesystem from a CMD prompt. I'm not a Windows expert though, and welcome a better or more standardized solution to this problem.
P.S.: I just found out the hard way that you need to ensure the "Start in:" property of any shortcut you use in this fashion is blanked out, or your program will not start in the directory you invoke the shortcut from.
P.P.S.: On a related note, I discovered how to run Windows Explorer (or its replacement) on the directory your CMD session is logged in to: start ..

Resources