Skip to content

Simulations don't run when nvidia-smi is unavailable #32

@david-zwicker

Description

@david-zwicker

I tried running simulations using the torch backend on my mac laptop, which does not have an Nvidia GPU. The simulation then fails because the profiler does not work (see error message below). It would be great if the package also worked with just the cpu device of torch. In any case, the hard-coded use of nvidia-smi implicitly assumes that torch uses the cuda backend, which is not general (and might led to problems in the future when other backends become more common).

[...]

File ~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/evoxels/solvers.py:122, in TimeDependentSolver._handle_outputs(self, u, frame, time, slice_idx, vtk_out, verbose, plot_bounds, colormap)
    119     self.vf.fields[name] = self.vg.export_scalar_field_to_numpy(u_out[i:i+1])
    121 if verbose:
--> [122](https://file+.vscode-resource.vscode-cdn.net/Users/dzwicker/Documents/Referee%20Reports/2026-01_JOSS/evoxels/docs/notebooks/~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/evoxels/solvers.py:122)     self.profiler.update_memory_stats()
    124 if self.vg.lib.isnan(u_out).any():
    125     print(f"NaN detected in frame {frame} at time {time}. Aborting simulation.")

File ~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/evoxels/profiler.py:27, in MemoryProfiler.update_memory_stats(self)
     25 self.max_used_cpu = np.max((self.max_used_cpu, used_cpu))
     26 used = self.get_cuda_memory_from_nvidia_smi()
---> [27](https://file+.vscode-resource.vscode-cdn.net/Users/dzwicker/Documents/Referee%20Reports/2026-01_JOSS/evoxels/docs/notebooks/~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/evoxels/profiler.py:27) self.max_used_gpu = np.max((self.max_used_gpu, used))

File ~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:3123, in max(a, axis, out, keepdims, initial, where)
   3011 @array_function_dispatch(_max_dispatcher)
   3012 @set_module('numpy')
   3013 def max(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
   3014          where=np._NoValue):
   3015     """
   3016     Return the maximum of an array or maximum along an axis.
   3017 
   (...)   3121     5
   3122     """
-> [3123](https://file+.vscode-resource.vscode-cdn.net/Users/dzwicker/Documents/Referee%20Reports/2026-01_JOSS/evoxels/docs/notebooks/~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:3123)     return _wrapreduction(a, np.maximum, 'max', axis, None, out,
   3124                           keepdims=keepdims, initial=initial, where=where)

File ~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:83, in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
     80         else:
     81             return reduction(axis=axis, out=out, **passkwargs)
---> [83](https://file+.vscode-resource.vscode-cdn.net/Users/dzwicker/Documents/Referee%20Reports/2026-01_JOSS/evoxels/docs/notebooks/~/user/miniconda3/envs/voxenv/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:83) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

TypeError: '>=' not supported between instances of 'int' and 'NoneType'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions