Shell script & "nvidia-smi" - needs right command/flag!

ricksebak
Member
Member
Posts: 33
Joined: February 10th, 2013, 9:34 pm

Re: Shell script & "nvidia-smi" - needs right command/flag!

Post by ricksebak »

In fact, a while loop could work better than a for loop, since a while loop will still work with any number of GPU cores:

cat /tmp/nvidaoutput | while read line
> do
> newstr=$(echo $line | awk '{print $7}')
> echo $newstr
> done
49
39
44
47
danhansen@denmark
Member
Member
Posts: 14
Joined: May 27th, 2013, 3:43 pm

Re: Shell script & "nvidia-smi" - needs right command/flag!

Post by danhansen@denmark »

Hi Riksebak,

Sorry my friend. I'm a newbie....

Code: Select all

# cat /tmp/nvidaoutput
cat: /tmp/nvidaoutput: No such file or directory
I'm running a Headless Ubuntu Server with CUDA70 and the nvidia driver which comes along with the .deb package. This does several things to a system which changes a lot of factors. E.g. your last suggestion, it doesn't give any output ;(
ricksebak
Member
Member
Posts: 33
Joined: February 10th, 2013, 9:34 pm

Re: Shell script & "nvidia-smi" - needs right command/flag!

Post by ricksebak »

TLDR: Change line 36 of your script to newstr=$(echo $str | awk '{print $7}') and it should work.

Longer version: I don't have an nvidia card, so I have no way to run nvidia-smi -q -d temperature | grep GPU | perl -pe '/^GPU/ && s/\n//' | grep ^GPU "GPU 0000:0$i:00.0". So in my example, I simply copied the output of your nvidia-smi command into a temporary file, catted that file, and used it just as an example so that you can see how I am setting str and newstr. So in my example, cat /tmp/nvidiaoutput would be equivalent to your nvidia-smi command.
danhansen@denmark
Member
Member
Posts: 14
Joined: May 27th, 2013, 3:43 pm

Re: Shell script & "nvidia-smi" - needs right command/flag!

Post by danhansen@denmark »

Hi Ricksebak,

"...So in my example, cat /tmp/nvidiaoutput would be equivalent to your nvidia-smi command..."

Sorry, I'm a rookie !! I should have known that, I can see that now. But, I got it to work, and when I've finished the whole ToDo I'll put it inhere for others to learn from! The basic script came from inhere some years back ;)

Thanks a lot my friend, for all the feedbacks.. Thanks!!
Have a nice weekend ;)

Kind Regards
Dan
Aaronsword
Member
Member
Posts: 3
Joined: September 7th, 2017, 3:13 pm

Shell script "nvidia smi" needs right command/flag

Post by Aaronsword »

hello every one,


I cannot actually understand what is the difference between the mailbox and normal command mode.
both of them look similar in their functionality. I think there is some priority difference, i.e. may be mailbox has more priority than normal cmd mode, but I am not sure. Of course they are somewhat difference but what best utilize them?


Can any one explain this with a little example?


Thanks
jaffry
Post Reply