Skip to content

Instantly share code, notes, and snippets.

View sghael's full-sized avatar

Sandeep Ghael sghael

  • Brookline, MA
View GitHub Profile
@sghael
sghael / cuda_reset.bash
Last active January 13, 2024 22:04
Code to solve `Triggered internally at ../c10/cuda/CUDAFunctions.cpp:108.) return torch._C._cuda_getDeviceCount() > 0` when un-suspending your Linux machine. I am using this on Ubuntu 22.04 with Nvidia Drivers 5.45 and Cuda 12.3
#!/bin/bash
# Function to find and kill gnome and xorg processes using the NVIDIA GPU
kill_gpu_processes() {
# Find Gnome and Xorg processes using the NVIDIA GPU
local gpu_processes=$(nvidia-smi | grep 'gnome\|xorg' | awk '{ print $5 }')
# Kill the processes gracefully
for pid in $gpu_processes; do
echo "Killing process with PID $pid"
kill $pid
@sghael
sghael / CUDA 11.8 on Ubuntu
Created November 25, 2023 18:00
CUDA on Ubuntu
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@sghael
sghael / it.rb
Last active August 29, 2015 13:56 — forked from anonymous/it.rb
def it(n)
x = [*2..n]
x.each do |i|
[*(i+1)..n].each { |j| x.delete(j) if (j%i).zero? }
end
end
# 1) what does it do?
# 2) how fast is it?
# 3) can you make it faster?
@sghael
sghael / colors.xml
Created June 14, 2012 13:43
Android colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="ivory">#FFFFF0</color>
<color name="light_yellow">#FFFFE0</color>
<color name="yellow">#FFFF00</color>
<color name="snow">#FFFAFA</color>
<color name="floral_white">#FFFAF0</color>
<color name="lemon_chiffon">#FFFACD</color>
<color name="cornsilk">#FFF8DC</color>