question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pin_memory option should be explicit in cell2location

See original GitHub issue

Dear developers, I was trying to run the following code:

import scvi
scvi.data.setup_anndata(adata=A1_fil, batch_key="in_tissue")
scvi.data.view_anndata_setup(A1_fil)

modA1fil = cell2location.models.Cell2location(
  A1_fil, cell_state_df=inf_aver_filraw,
  N_cells_per_location=8,
    detection_alpha=200)
modA1fil.train(max_epochs=40000,
          batch_size=None,
          train_size=1,
          use_gpu=True)`

After the print of scvi.data.view_anndata_setup(), Cell2Location recognize the GPU:

GPU available: True, used: True
TPU available: False, using: 0 TPU cores

but it does stop just afterwards with the following error: RuntimeError: cannot pin 'torch.cuda.FloatTensor' only dense CPU tensors can be pinned. I saw that it should be easily overcome if I can put pin_memory=False (see here) in cell2location model, how can I do that?

Best, Carlo

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
carloellecommented, Dec 2, 2021

yes it works smoothly!

1reaction
carloellecommented, Dec 2, 2021

Update: I tried to re-create another conda environment following the C2L installation tutorial to see if I could overcome this error, and indeed I succeed. the previous error vanishes and it starts the training of the model using GPU. I report here the list of correct packages for future reference:

Package                 Version
----------------------- ---------
absl-py                 1.0.0
aiohttp                 3.8.1
aiosignal               1.2.0
anndata                 0.7.8
argon2-cffi             21.1.0
arviz                   0.10.0
async-timeout           4.0.1
attrs                   21.2.0
backcall                0.2.0
bleach                  4.1.0
cachetools              4.2.4
cell2location           0.6a0
certifi                 2021.10.8
cffi                    1.15.0
cftime                  1.5.1.1
charset-normalizer      2.0.8
colorama                0.4.4
commonmark              0.9.1
cycler                  0.11.0
debugpy                 1.5.1
decorator               5.1.0
defusedxml              0.7.1
descartes               1.1.0
dill                    0.3.4
docrep                  0.3.2
entrypoints             0.3
et-xmlfile              1.1.0
fastprogress            1.0.0
fonttools               4.28.2
frozenlist              1.2.0
fsspec                  2021.11.1
future                  0.18.2
google-auth             2.3.3
google-auth-oauthlib    0.4.6
grpcio                  1.42.0
h5py                    3.6.0
idna                    3.3
igraph                  0.9.8
importlib-metadata      4.8.2
ipykernel               6.6.0
ipython                 7.30.0
ipython-genutils        0.2.0
ipywidgets              7.6.5
jedi                    0.18.1
Jinja2                  3.0.3
joblib                  1.1.0
jsonschema              4.2.1
jupyter-client          7.1.0
jupyter-core            4.9.1
jupyterlab-pygments     0.1.2
jupyterlab-widgets      1.0.2
kiwisolver              1.3.2
leidenalg               0.8.8
llvmlite                0.37.0
Markdown                3.3.6
MarkupSafe              2.0.1
matplotlib              3.5.0
matplotlib-inline       0.1.3
mistune                 0.8.4
mizani                  0.7.3
multidict               5.2.0
natsort                 8.0.0
nbclient                0.5.9
nbconvert               6.3.0
nbformat                5.1.3
nest-asyncio            1.5.4
netCDF4                 1.5.8
networkx                2.6.3
notebook                6.4.6
numba                   0.54.1
numexpr                 2.8.0
numpy                   1.20.3
oauthlib                3.1.1
opencv-python           4.5.4.60
openpyxl                3.0.9
opt-einsum              3.3.0
packaging               21.3
palettable              3.3.0
pandas                  1.3.4
pandocfilters           1.5.0
parso                   0.8.3
patsy                   0.5.2
pexpect                 4.8.0
pickleshare             0.7.5
Pillow                  8.4.0
pip                     21.2.4
plotnine                0.8.0
prometheus-client       0.12.0
prompt-toolkit          3.0.23
protobuf                3.19.1
ptyprocess              0.7.0
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycparser               2.21
pyDeprecate             0.3.0
Pygments                2.10.0
pymc3                   3.10.0
pynndescent             0.5.5
pyparsing               3.0.6
pyro-api                0.1.2
pyro-ppl                1.7.0
pyrsistent              0.18.0
python-dateutil         2.8.2
python-igraph           0.9.8
pytorch-lightning       1.3.8
pytz                    2021.3
PyYAML                  5.4.1
pyzmq                   22.3.0
requests                2.26.0
requests-oauthlib       1.3.0
rich                    10.15.2
rsa                     4.8
scanpy                  1.8.2
scikit-learn            1.0.1
scipy                   1.7.3
scvi-tools              0.14.5
seaborn                 0.11.2
Send2Trash              1.8.0
setuptools              58.0.4
setuptools-scm          6.3.2
sinfo                   0.3.4
six                     1.16.0
statsmodels             0.13.1
stdlib-list             0.8.0
tables                  3.6.1
tensorboard             2.7.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
terminado               0.12.1
testpath                0.5.0
texttable               1.6.4
Theano-PyMC             1.0.11
threadpoolctl           3.0.0
tomli                   1.2.2
torch                   1.10.0
torchmetrics            0.6.0
tornado                 6.1
tqdm                    4.62.3
traitlets               5.1.1
typing_extensions       4.0.1
umap-learn              0.5.2
urllib3                 1.26.7
wcwidth                 0.2.5
webencodings            0.5.1
Werkzeug                2.0.2
wheel                   0.37.0
widgetsnbextension      3.5.2
xarray                  0.20.1
xlrd                    1.2.0
yarl                    1.7.2
zipp                    3.6.0

Best, Carlo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common errors — cell2location documentation - Read the Docs
Solution: try removing genes detected at low levels in spatial data. 3. Theano fails to use the GPU at all (or cuDNN in...
Read more >
cell2location/cell2location_short_demo.ipynb at master - GitHub
This notebook demonstrates how to use the cell2location model for mapping a single cell reference cell types onto a spatial transcriptomic dataset.
Read more >
cell2location - Wellcome Sanger Institute
Cell2location maps the spatial distribution of cell types by integrating single-cell RNA-seq (scRNA-seq) and multi-cell spatial transcriptomic data from a given ...
Read more >
Vitalii Kleshchevnikov on Twitter: "My 1st paper out in ...
Tons of new work showing that we can resolve fine cell types in spatial ... We present 1) cell2location method, 2) show how...
Read more >
Mapping human lymph node cell types to 10X Visium with ...
Cell2location is a principled Bayesian model that estimates which combination of cell types in which cell abundance could have given the mRNA counts...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found