Skip to content

Instantly share code, notes, and snippets.

#!/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
def sample_pts(x, delta):
""" Given points X sample points that are shifted by delta in axis aligned directions """
points = torch.stack(
[
x + torch.as_tensor([delta, 0.0, 0.0]).to(x),
x + torch.as_tensor([-delta, 0.0, 0.0]).to(x),
x + torch.as_tensor([0.0, delta, 0.0]).to(x),
x + torch.as_tensor([0.0, -delta, 0.0]).to(x),
x + torch.as_tensor([0.0, 0.0, delta]).to(x),
x + torch.as_tensor([0.0, 0.0, -delta]).to(x),
## find right version on https://download.blender.org/release/ and copy the link
wget https://download.blender.org/release/Blender4.0/blender-4.0.2-linux-x64.tar.xz
# unpack
tar xf blender-4.0.2-linux-x64.tar.xz
# move it and link so can be used via terminal
sudo mv blender-4.0.2-linux-x64/ /opt/blender
sudo ln -s /opt/blender/blender /usr/bin/blender
import bpy
bpy.data.scenes[0].render.engine = "CYCLES"
# Set the device_type
bpy.context.preferences.addons[
"cycles"
].preferences.compute_device_type = "CUDA" # or "OPENCL"
# Set the device and feature set
bpy.context.scene.cycles.device = "GPU"
#!/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