odlgroup / odl

Operator Discretization Library https://odlgroup.github.io/odl/
Mozilla Public License 2.0
371 stars 105 forks source link

Docs are unclear about optional dependencies (in particular ray trafo backends) #1562

Open james-zhang-jz opened 4 years ago

james-zhang-jz commented 4 years ago
import tensorflow as tf
import numpy as np
import odl
import odl.contrib.tensorflow
from util import random_phantom, conv2d

sess = tf.compat.v1.InteractiveSession()

# Create ODL data structures
size = 128
space = odl.uniform_discr([-64, -64], [64, 64], [size, size],
                          dtype='float32')

geometry = odl.tomo.parallel_beam_geometry(space, num_angles=30)
operator = odl.tomo.operators.ray_trafo.RayTransform(space, geometry)
pseudoinverse = odl.tomo.fbp_op(operator)

# Ensure operator has fixed operator norm for scale invariance
opnorm = odl.power_method_opnorm(operator)
operator = (1 / opnorm) * operator
pseudoinverse = pseudoinverse * opnorm

I was running these lines of code and the error was raised at where I define the operator using RayTransform.

I have followed the instruction on the ODL docs page and installed all the packages, extensions and dependencies with pip install

I have a feeling that this is caused by a trivial mistake, if anyone has dealt with the same issue, please help asap.

Much appreciated! Cheers

kohr-h commented 4 years ago

Hey @james-zhang-jz ! You need to install a package for the computation of ray transforms, preferably the ASTRA toolbox. Admittedly the docs are not very clear about this, but I also don't think that the pip path is optimal as the ASTRA toolbox does not provide wheels. You'd need to compile it from source to install it. With conda it would be much easier, I suggest that you consider going that path.

kohr-h commented 4 years ago

On our side, I think we should restructure the install docs a bit, with a separate section about optional packages and more prominent references to it.

james-zhang-jz commented 4 years ago

I think I have resolved the issue by using the miniconda environment with the ODL specified version of python 3.5. However, I have other issues that link with different versions of packages.

Could you specify the version of packages you are using in this project such as tensorflow? I am getting errors like tensorflow packages has no attributes xxxxxxxxxx. It looks like it is caused by using a different version of packages.

Thanks in advance.

kohr-h commented 4 years ago

I'm not an expert on the TF integration, @adler-j should know more.

What I suspect, though, is that our TF code is based on the 1.x API and breaks with tensorflow 2.x. I know the old API is still supported, but probably requires some changes in the import. You can try to install a 1.x version of tensorflow and see if it works.

adler-j commented 4 years ago

You can run import tensorflow.compat.v1 as tf, but we should fix TF2 support as well. Could you link the error messages you are getting?

james-zhang-jz commented 4 years ago

Thank you both for the feedback, I will post the error once I am certain with the cause of it. Let me explore some more and get back to you guys.

Thanks again!

james-zhang-jz commented 4 years ago

Hi again,

I have successfully installed the pack on one machine without problems, and now trying to install it on a remote machine. I have encountered the following issue when installing with the following command: CUDA_ROOT=/usr/local/cuda CUDA_COMPUTE=30 conda build ./conda I have the CUDA_ROOT set to the /usr/local/cuda directory.

I am not sure whether it is the problem with the remote machine or the odlcuda packages, sorry for the interruption.

Please assist, thanks in advance. [ Screen Shot 2020-05-30 at 14 34 40

adler-j commented 4 years ago

You shouldn't need odlcuda. Why is it being installed here?

james-zhang-jz commented 4 years ago

Thanks for your response, I didn't read the warnings carefully on your docs.