I want to use deepxde with the pytorch backend on my gpu (7800xt), however I get the following error:
rocblaslt error: Cannot read /home/miga/Documents/GitHub/Reacto-Difuso/.devenv/profile/lib/hipblaslt/library/TensileLibrary_lazy_gfx1101.dat: No such file or directory
rocblaslt error: Could not load /home/miga/Documents/GitHub/Reacto-Difuso/.devenv/profile/lib/hipblaslt/library/TensileLibrary_lazy_gfx1101.dat
And then pytorch crashes. The weird thing is I can use it on another project with only a warning popping up:
Attempting to use hipBLASLt on an unsupported architecture! Overriding blas backend to hipblas
I tried googling on the pytorch side but no luck, the same error isn’t reported, but similar ones are. I’m starting to think it’s an issue with my devenv. Here is my devenv flake:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-python.url = "github:cachix/nixpkgs-python";
nixpkgs-python.inputs = { nixpkgs.follows = "nixpkgs"; };
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
rocmSupport = true;
};
outputs = { self, nixpkgs, devenv, systems, ... } @ inputs:
let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
packages = forEachSystem (system: {
devenv-up = self.devShells.${system}.default.config.procfileScript;
devenv-test = self.devShells.${system}.default.config.test;
});
devShells = forEachSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
rocmSupport = true;
};
};
in
{
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
({ pkgs, config, inputs, ... }:
{
# https://devenv.sh/packages/
packages = [
pkgs.git
pkgs.python312Packages.torchWithRocm
pkgs.python312Packages.torchvision
pkgs.rocmPackages.rocblas
pkgs.rocmPackages.hipblas
pkgs.rocmPackages.hipblaslt
pkgs.rocmPackages.clr
];
# https://devenv.sh/languages/
languages.python.enable = true;
languages.python.version = "3.12.8";
languages.python.venv.enable = true;
languages.python.venv.requirements = ./requirements.txt;
scripts.hello.exec = ''
echo hello!
'';
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
git --version | grep --color=auto "${pkgs.git.version}"
'';
})
];
};
});
};
}
I would really appreciate help, any insight you have could be useful. Here’s an example of what I am trying to get working, taken from the deepxde examples, if you want to test stuff:
"""Backend supported: tensorflow.compat.v1, tensorflow, pytorch, paddle"""
import deepxde as dde
import numpy as np
def heat_eq_exact_solution(x, t):
"""Returns the exact solution for a given x and t (for sinusoidal initial conditions).
Parameters
----------
x : np.ndarray
t : np.ndarray
"""
return np.exp(-(n**2 * np.pi**2 * a * t) / (L**2)) * np.sin(n * np.pi * x / L)
def gen_exact_solution():
"""Generates exact solution for the heat equation for the given values of x and t."""
# Number of points in each dimension:
x_dim, t_dim = (256, 201)
# Bounds of 'x' and 't':
x_min, t_min = (0, 0.0)
x_max, t_max = (L, 1.0)
# Create tensors:
t = np.linspace(t_min, t_max, num=t_dim).reshape(t_dim, 1)
x = np.linspace(x_min, x_max, num=x_dim).reshape(x_dim, 1)
usol = np.zeros((x_dim, t_dim)).reshape(x_dim, t_dim)
# Obtain the value of the exact solution for each generated point:
for i in range(x_dim):
for j in range(t_dim):
usol[i][j] = heat_eq_exact_solution(x[i], t[j])
# Save solution:
np.savez("heat_eq_data", x=x, t=t, usol=usol)
def gen_testdata():
"""Import and preprocess the dataset with the exact solution."""
# Load the data:
data = np.load("heat_eq_data.npz")
# Obtain the values for t, x, and the excat solution:
t, x, exact = data["t"], data["x"], data["usol"].T
# Process the data and flatten it out (like labels and features):
xx, tt = np.meshgrid(x, t)
X = np.vstack((np.ravel(xx), np.ravel(tt))).T
y = exact.flatten()[:, None]
return X, y
# Problem parameters:
a = 0.4 # Thermal diffusivity
L = 1 # Length of the bar
n = 1 # Frequency of the sinusoidal initial conditions
# Generate a dataset with the exact solution (if you dont have one):
gen_exact_solution()
def pde(x, y):
"""Expresses the PDE residual of the heat equation."""
dy_t = dde.grad.jacobian(y, x, i=0, j=1)
dy_xx = dde.grad.hessian(y, x, i=0, j=0)
return dy_t - a * dy_xx
# Computational geometry:
geom = dde.geometry.Interval(0, L)
timedomain = dde.geometry.TimeDomain(0, 1)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)
# Initial and boundary conditions:
bc = dde.icbc.DirichletBC(geomtime, lambda x: 0, lambda _, on_boundary: on_boundary)
ic = dde.icbc.IC(
geomtime,
lambda x: np.sin(n * np.pi * x[:, 0:1] / L),
lambda _, on_initial: on_initial,
)
# Define the PDE problem and configurations of the network:
data = dde.data.TimePDE(
geomtime,
pde,
[bc, ic],
num_domain=2540,
num_boundary=80,
num_initial=160,
num_test=2540,
)
net = dde.nn.FNN([2] + [20] * 3 + [1], "tanh", "Glorot normal")
model = dde.Model(data, net)
# Build and train the model:
model.compile("adam", lr=1e-3)
model.train(iterations=20000)
model.compile("L-BFGS")
losshistory, train_state = model.train()
# Plot/print the results
dde.saveplot(losshistory, train_state, issave=True, isplot=True)
X, y_true = gen_testdata()
y_pred = model.predict(X)
f = model.predict(X, operator=pde)
print("Mean residual:", np.mean(np.absolute(f)))
print("L2 relative error:", dde.metrics.l2_relative_error(y_true, y_pred))
np.savetxt("test.dat", np.hstack((X, y_true, y_pred)))