Skip to content

Commit

Permalink
fix: sending images to the vscode extension fails, if the tensor is n…
Browse files Browse the repository at this point in the history
…ot local to the cpu (#63)

Related-to: Safe-DS/DSL#954 (the PR requires
this fix to work)

Fixes the following error: 

`RuntimeError: Attempted to send CUDA tensor received from another
process; this is not currently supported. Consider cloning before
sending.`

This error only occurs on systems that support graphics acceleration of
tensor operations.
On other systems, the tensor is local to the CPU by default and does not
need to be converted.
The conversion process is a noop, if the tensor is already local to the
CPU.

---------

Co-authored-by: megalinter-bot <[email protected]>
  • Loading branch information
WinPlay02 and megalinter-bot authored Apr 2, 2024
1 parent 14ff8cc commit 8cf0b57
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 166 deletions.
6 changes: 6 additions & 0 deletions src/safeds_runner/server/_pipeline_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ def save_placeholder(self, placeholder_name: str, value: Any) -> None:
value : Any
Actual value of the placeholder.
"""
from safeds.data.image.containers import Image

if isinstance(value, Image):
import torch

value = Image(value._image_tensor, torch.device("cpu"))
self._placeholder_map[placeholder_name] = value
placeholder_type = _get_placeholder_type(value)
self._send_message(
Expand Down
Loading

0 comments on commit 8cf0b57

Please sign in to comment.