-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtensor_run.win.ps1
57 lines (46 loc) · 1.82 KB
/
tensor_run.win.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Experimental Windows Port
function CheckAndSetNumaNodes {
$numaNodeStatus = 0
$paths = Get-ChildItem -Path "C:\sys\bus\pci\devices\*" -Filter numa_node -File
foreach ($path in $paths) {
if ((Get-Content $path.FullName) -ne "0") {
$numaNodeStatus = 1
break
}
}
if ($numaNodeStatus -eq 1) {
Write-Host "Not all NUMA nodes are set to 0. Do you want to set all NUMA nodes to 0? [y/n]"
$answer = Read-Host
if ($answer -eq "y") {
Write-Host "Setting all NUMA nodes to 0 with sudo..."
foreach ($path in $paths) {
"0" | Set-Content $path.FullName
}
Write-Host "All NUMA nodes have been set to 0."
} else {
Write-Host "Continuing without changing NUMA nodes."
}
} else {
Write-Host "All NUMA nodes are already set to 0."
}
}
function Tensor {
$image = "tensor"
$baseCommand = "docker run -p 8888:8888 --gpus all -it -v ${PWD}:/home/phonon/workingdir -v /tmp/.X11-unix:/tmp/.X11-unix --env DISPLAY=$env:DISPLAY $image"
CheckAndSetNumaNodes
Start-Process -FilePath "xhost" -ArgumentList "+local:tensor"
if ([string]::IsNullOrEmpty($args[0])) {
Write-Host "Starting interactive TensorFlow GPU session..."
Invoke-Expression "$baseCommand zsh"
} else {
$scriptPath = $args[0]
if (-Not (Test-Path $scriptPath)) {
Write-Host "Error: Script '$scriptPath' does not exist."
return
}
Write-Host "Running Python script '$scriptPath' in the TensorFlow container..."
Invoke-Expression "$baseCommand bash -c 'cd /home/phonon/workingdir && python $scriptPath; exec bash'"
}
Start-Process -FilePath "xhost" -ArgumentList "-local:tensor"
}
Write-Host "Function tensor defined."