一年前,一台 4K 電視回家了,上週終於有了一款可以以該解析度驅動電視的顯示卡。 該卡有一個巨大的散熱器,但沒有風扇。 沒有風扇意味著不會產生太多熱量(我希望如此),這意味著古老的 250W 電源所需的功率更少。 電腦運行Linux,在網路上查了一下,我發現這些指令可以檢查機殼內的溫度感測器。 綠色的Netflix是 Linux 電腦的名稱。
nvidia-settings and sensors commands to show temperaturenvidia-settings and sensors commands to show temperaturenvidia-settings and sensors commands to show temperaturenvidia-settings and sensors commands to show temperaturenvidia 設定和感測器指令顯示溫度
這兩個指令顯示 Nvidia(顯示卡)溫度為 53C,CPU 溫度為 46C 到 53C。 感測器命令似乎也表明 80C 是令人擔憂的社區的開始。 目前,在寫這篇文章時顯示卡處於空閒狀態,溫度很低。 顯示全螢幕4K影片會比較吃力,溫度也會升高。 多少、多快?
為了找到答案,JMP 將循環運行 Linux 命令,記錄結果並製作一個隨著資料收集而更新的圖表。 神奇之處在於 RunProgram(一個 JSL 函數)和 plink(一個外部程序,putty 套件的一部分,在 Windows 上運行)。在此之前,需要做一些事情。
首先,Linux 主機需要執行 SSH 伺服器,並且需要適當保護。 我使用過類似的網站這和這這是為了解決這個問題。
接下來,您需要在 Windows 電腦上安裝 plink。 我選擇了msi安裝程序這裡然後閱讀這弄清楚 plink 是如何運作的。
最後,配置 puttygen/putty/plink 以使用帶有金鑰的 ssh 連線(相同這從上面),這樣您就不會將密碼放在顯眼的地方。
現在運行一個非常簡單的測試,看看一切是否都就位。 普林克是您的 Windows 電腦將要執行的程式(putty 安裝的一部分)。 Netflix也是我的Linux計算機在putty程式中的設定名稱。感應器是 Linux 電腦將運行的程式的名稱。 和文字告訴 RunProgram 在感測器完成後僅返回感測器的所有文字輸出。
Output of sensors command showing B0 for degree symbolOutput of sensors command showing B0 for degree symbolOutput of sensors command showing B0 for degree symbolOutput of sensors command showing B0 for degree symbol感測器指令的輸出顯示 B0 表示度數符號
高亮顯示的 B0 應該是度數符號。 RunProgram 假設可執行檔的輸出為 7 位元 ASCII,而非 Unicode。 若要解決此問題,請使用 blob 選項並將 blob 轉換為文字。 此範例將運行兩個命令。 保存命令的 JSL 字串在引號內使用 \[ 和 ]\ 字符,以便以後在需要時更容易使用特殊字符。 分號分隔兩個 Linux 指令。 您可以看到感興趣的黃色高亮值,後面是度數符號(不是 B0)。
RunProgram with the blob option returns binary data which might convert to UnicodeRunProgram with the blob option returns binary data which might convert to UnicodeRunProgram with the blob option returns binary data which might convert to UnicodeRunProgram with the blob option returns binary data which might convert to Unicode帶有 blob 選項的 RunProgram 傳回可能轉換為 Unicode 的二進位數據
重複創建與 Linux 電腦的連接是可以的,但並不理想。 創建一次就可以避免開銷。 我將透過編寫一個讓 Linux 電腦運行的循環來實現這一點,並有短暫的延遲。 ReadFunction 仍然會得到一個 blob,但它將成為一個實際的 JSL 函數,從 Linux 電腦取得文字區塊。 這些區塊被連接在一起,解析感興趣的值,並將值添加到資料表中。
// open a data table to record results
dt = New Table( "temperature",
New Column( "time", Format( "hr:m:s", 13, 0 ) ),
New Column( "gpu" ),
New Column( "PhysicalID0" ),
New Column( "Core0" ),
New Column( "Core1" ),
New Column( "Core2" ),
New Column( "Core3" )
);
start = Tick Seconds(); // capture initial time to subtract out later
buffer = Char To Blob( "" ); // buffer several reads together; init to empty
rp = RunProgram( // launch the long-running external program; note the shell command "while [ 1 ]" and the "sleep 2"
executable( "plink" ),
options( {"netflix", "\[while [ 1 ]; do nvidia-settings -c :0 -q gpucoretemp; sensors; sleep 2; done]\"} ), // inxi -Fxz
readfunction(
Function( {this}, {},
While( this << canread,
buffer = buffer || (this << read( "blob" ));
Wait( 0.1 ); // try to grab up all of the output for each 2-second report
);
If( Length( buffer ) > 0, // not always
text = Blob To Char( buffer ); // there is a remote possibility a unicode sequence gets split here
buffer = Char To Blob( "" ); // reset empty
dt << addrow( 1 ); // build the table
dt:time = Tick Seconds() - start; // apply offset to get 0 time for start
dt:gpu = Num( Regex( text, "\[Attribute 'GPUCoreTemp' \(Netflix.local:0.0\): (\d+)]\", "\1" ) );
dt:PhysicalID0 = Num( Regex( text, "\[Physical id 0: \+(\d+)]\", "\1" ) );
dt:Core0 = Num( Regex( text, "\[Core 0: \+(\d+)]\", "\1" ) );
dt:Core1 = Num( Regex( text, "\[Core 1: \+(\d+)]\", "\1" ) );
dt:Core2 = Num( Regex( text, "\[Core 2: \+(\d+)]\", "\1" ) );
dt:Core3 = Num( Regex( text, "\[Core 3: \+(\d+)]\", "\1" ) );
//write("\!n", gpu," ",PhysicalID0," ",Core0," ",Core1," ",Core2," ",Core3 );
);
)
)
);
Wait( 10 ); // wait for a few rows before launching
dt << Graph Builder(
Size( 679, 444 ),
Show Control Panel( 0 ),
Variables(
X( :time ),
Y( :gpu ),
Y( :PhysicalID0, Position( 1 ) ),
Y( :Core0, Position( 1 ) ),
Y( :Core1, Position( 1 ) ),
Y( :Core2, Position( 1 ) ),
Y( :Core3, Position( 1 ) )
),
Elements( Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 ), Y( 6 ), Legend( 4 ), Lambda( 4.32912374502826 ) ) ),
SendToReport(
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Temperatures" )} ),
Dispatch( {}, "X title", TextEditBox, {Set Text( "H:M:S" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Centigrade" )} )
)
);
Wait( 10000 ); // wait 10,000 seconds, then...
rp = 0; // kill it. it is in a loop.
The 5 non-GPU temperatures track togetherThe 5 non-GPU temperatures track togetherThe 5 non-GPU temperatures track togetherThe 5 non-GPU temperatures track together5 個非 GPU 溫度一起追蹤
《螢火蟲》兩集。 最初的 15 分鐘是滾動瀏覽選項,尋找值得觀看的內容。 影片結束後的最後幾分鐘是 CPU 硬循環。 我不小心在 10,000 秒之前結束了程序。