plotly: specify GPU for figure output

Viewed 350

I have two GPUs on the same machine. I wrote a function to output 3D contour map using plotly. One GPU is outdated and is used only for moniter graphics. Is there a way to do specify plotly graphics only on the other faster GPU?

Here is the sample code for the visualization.

M = np.zeros(64, 64, 64)
X, Y, Z = np.mgrid[0:1:64, 0:1:64, 0:1:64]

try:
    fig = go.Figure(data=go.Volume(
        x=Z.flatten(),
        y=Y.flatten(),
        z=X.flatten(),
        value=M.flatten(),
        opacity=.1,
        surface_count=15,
        cmax=1.,
        cmin=0.
    ))

    # figure IO
    fig.write_image('image.png')
    if show:
        fig.show()

except (OSError, ValueError):
    print('Unable to generate plotly figure')

Edit 1:

CUDA_VISIBLE_DEVICE=0 python myscript.py does not seem to help. Same applies to os.environ('CUDA_VISIBLE_DEVICE') = 0.

0 Answers
Related