Open kmh005 opened 3 years ago
Hi @kmh005, I had the exact same issue.
About a year ago I used cellassign in R3.6.x and had great results. Then I put aside the project for a while to work on something else. Recently I come back to use cellassign and attempted to re-run the pipeline with some new data. Now my R is upgraded to 4.0.3. I received the exact warnings and errors as you do.
I managed to get rid of the TensorRT warning by re-configuring cuda and tensorflow versions. I had cuda 11.0 installed which requires Tensorflow>=2.4.0. Inspired by this thread, I upgraded tensorflow and tensorflow-gpu to 2.4.0, and the warning was resolved:
# Create independent conda env and install tensorflow(-gpu, -probability) from shell
conda create -n cellassign
conda activate cellassign
pip install --upgrade pip
pip install tensorflow==2.4.0
pip install tensorflow-gpu==2.4.0
pip install tensorflow-probability==0.12.0
Then in R:
> install.packages("tensorflow")
> reticulate::use_condaenv("cellassign")
> library(tensorflow)
> tensorflow::tf_config()
2021-12-02 14:24:33.313201: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
Loaded Tensorflow version 2.4.0
TensorFlow v2.4.0 (~/miniconda3/envs/cellassign/lib/python3.7/site-packages/tensorflow)
Python v3.7 (~/miniconda3/envs/cellassign/bin/python)
The cuda & tensorflow compatibility can be found here in case you need it.
But still, running cellassign
on example dataset raised error. So TensorRT was not at the center of the issue.
> library(cellassign)
> data(example_sce)
> data(example_marker_mat)
> s <- SingleCellExperiment::sizeFactors(example_sce)
> fit <- cellassign(exprs_obj = example_sce[rownames(example_marker_mat),],
+ marker_gene_info = example_marker_mat,
+ s = s,
+ learning_rate = 1e-2,
+ shrinkage = TRUE,
+ verbose = FALSE)
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: Tried to convert 'shape' to a tensor and failed.
Error: Cannot convert a partially known TensorShape to a Tensor: (1, ?)
I also tried reinstalling R 3.6 and the issue persists.
@kmh005 Possible solution: install R tensorflow
package via devtools
and explicitly specify a version. #94
I tried to install a lower version of R and tensorflow. Unfortunately, the issue still occurred.
Following the issue tip, I modified line 165 of the inference-tensorflow.R
file, and then, it worked.
p_y_on_c_norm <- tf$reshape(tf$reduce_logsumexp(p_y_on_c_unorm, 0L), as_tensor(shape(1,NULL)))
I tried to install a lower version of R and tensorflow. Unfortunately, the issue still occurred.
Following the issue tip, I modified line 165 of the
inference-tensorflow.R
file, and then, it worked.p_y_on_c_norm <- tf$reshape(tf$reduce_logsumexp(p_y_on_c_unorm, 0L), as_tensor(shape(1,NULL)))
The current solution is therefore:
inference-tensorflow.R
as fixed by @WangDaMiao97, and push itdevtools::install_github("your_fork/cellassign")
That's it, nothing less, nothing more. No need for local Python environment or downgrading to another version of TensorFlow.
sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)
other attached packages:
cellassign_0.99.21
tensorflow_2.9.0
Hi, I used this tool in the past in an older version of R and Python (3.6.2 and 3.6.3 respectively), and it worked like a charm, and thanks for your input to my imbalanced marker set question. Given the times I'm trying a new install of CellAssign in R 4.1.0 with Python 3.8.3. I originally tried the TF/TF probability install with default versions in a fresh conda environment, but got the below error, so I started a new conda environment and went with an older TF/TF probability 2.1.0. That didn't change the error, below.
I start the session as follows, and check tf:config() to a warning about TensorRT but otherwise successful load, proceed with the workflow below, and include my sessionInfo().
My SCE object is 2449 cells and 157 genes after marker filtering. I used the same 157 markers on a 6k cell object previously to no issues.
Any help or pointers you could provide would be greatly appreciated. Thanks!