Open GarretOConnell opened 2 years ago
Hi @GarretOConnell ,
What I suspect is happening here is that the build process for tfcausalimpact is linux based.
Maybe the conflict comes from the macOS environment. What we probably need to do is to update our build scripts to contemplate other OSes as well (unfortunately I won't be able to do so in the near term).
One possibility to work around this issue is to use a docker-linux based image where installation is expected to work cleanly.
I'll leave this issue open for now and when I have some available time I'll research into building the package for all OSes.
Best,
Will
[EDIT April 26, 2022]:
We just updated our CICD workflow to add the MacOS environment as well but everything is working fine as expected there. We are still not sure why some people are having this issue (apparently) on M1 Macs.
Hi, @WillianFuks What linux version should I use? When I use Ubuntu 20.04.2, I got error like this: ERROR: Could not find a version that satisfies the requirement tensorflow (from tf causalimpact) (from versions: none)
Hi @jamesfyp ,
Any ubuntu version should satisfy I suppose as TF is built to attend all of them. Maybe could it be a Python version that is still not contemplated by TF yet? Is there anything else in the trace stack?
Hey everyone,
I also installed Tensorflow following the same instructions @GarretOConnell did on my M1 Mac and received the exact same error message. I could resolve this error message by simply doing conda install python=3.8
& conda install tensorflow
. The default Python version installed in the conda environment is 3.9, which is not compatible with tfcausalimpact and the name of the tensforflow package installed by the Apple developer Guide is 'tensorflow-macos', but I guess tfcausalimpact expects it to be called just 'tensorflow'.
After I ran pip install tfcausalimpact
again, the output said the following: INFO: pip is looking at multiple versions of matplotlib to determine which version is compatible with other requirements. This could take a while.
Pip then downloaded all versions back until 1.3.1, which seems to not be compatible with Python3. The install command then throws an error, because it is not possible to install matplotlib 1.3.1 on Python3 in order to find the compatible version for tfcausalimpact.
To bypass this error I set a specific version of matplotlib for the installation: pip install tfcausalimpact "matplotlib == 3.5.1"
. The installation took some time, but it worked out in the end.
To test, if everything works as expected, I copied the example code given in the readme of this repository and received and error saying that I could not import pandas, due to some numpy array issues between C and Py0bject. Unfortunately, I did not copy this error and am not able to reproduce to give you the exact error message I've received. I resolved this issue by doing pip install --upgrade numpy
. Afterwards I received the expected result of the readme example. However, I received the following warnings:
WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:From /Users/brummue/miniforge3/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py:463: StructuralTimeSeries.joint_log_prob (from tensorflow_probability.python.sts.structural_time_series) is deprecated and will be removed after 2022-03-01. Instructions for updating: Please use 'StructuralTimeSeries.joint_distribution(observed_time_series).log_prob' WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:From /Users/brummue/miniforge3/lib/python3.8/site-packages/tensorflow_probability/python/distributions/distribution.py:345: calling MultivariateNormalDiag.__init__ (from tensorflow_probability.python.distributions.mvn_diag) with scale_identity_multiplier is deprecated and will be removed after 2020-01-01. Instructions for updating: 'scale_identity_multiplier' is deprecated; please combine it into 'scale_diag' directly instead. WARNING:tensorflow:From /Users/brummue/miniforge3/lib/python3.8/site-packages/tensorflow/python/ops/linalg/linear_operator_block_diag.py:238: LinearOperator.graph_parents (from tensorflow.python.ops.linalg.linear_operator) is deprecated and will be removed in a future version. Instructions for updating: Do not call 'graph_parents'. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass. WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass.
2022-04-25 10:27:29.798853: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2) 2022-04-25 10:27:29.932154: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
WARNING:tensorflow:From /Users/brummue/miniforge3/lib/python3.8/site-packages/causalimpact/model.py:408: calling one_step_predictive (from tensorflow_probability.python.sts.forecast) with timesteps_are_event_shape=True is deprecated and will be removed after 2021-12-31. Instructions for updating: 'Predictive distributions returned by 'tfp.sts.one_step_predictive' will soon compute per-timestep probabilities (treating timesteps as part of the batch shape) instead of a single probability for an entire series (the current approach, in which timesteps are treated as event shape). Please update your code to pass 'timesteps_are_event_shape=False' (this will soon be the default) and to explicitly sum over the per-timestep log probabilities if this is required. WARNING:tensorflow:From /Users/brummue/miniforge3/lib/python3.8/site-packages/tensorflow_probability/python/distributions/distribution.py:345: MultivariateNormalFullCovariance.__init__ (from tensorflow_probability.python.distributions.mvn_full_covariance) is deprecated and will be removed after 2019-12-01. Instructions for updating: 'MultivariateNormalFullCovariance' is deprecated, use 'MultivariateNormalTriL(loc=loc, scale_tril=tf.linalg.cholesky(covariance_matrix))' instead.
My question to you @WillianFuks is, if those warnings are okay, I successfully installed tfcausalimpact and therefore could resolve this issue?
Thanks in advance!
Hi @seccobo1 ,
Those warnings are totally fine. They are mainly part of tensorflow probability and so far we couldn't find a way of turning them off without also turning off all other warnings from the system so that's why those remain.
As an update, the latest version of tfcausalimpact
deployed is tested on a MacOS environment as well but everything works fine there. Why we are having this issue on M1 Macs (as it seems) remains unexplained; it does seem related to the support of the tensorflow packages but this is not certain for now.
Hopefully the docker workaround solves the problem in the meantime.
Best,
Will
Hi everyone,
I'm having trouble getting the example code in the readme of this repository to run. I'm also running it on Apple M1 Max chip, macOS 12.5, so I thought this thread would be most relevant.
Here are the steps I took and the error I'm getting.
I followed https://developer.apple.com/metal/tensorflow-plugin/ to download miniforge, install tensorflow-deps, tensorflow-macos and tensorflow-metal. As suggested by @seccobo1, I also ran conda instsall tensorflow
, so that pip install tfcausalimpact
was successful.
After installing other dependencies (matplotlib, pandas, tensorflow_probability) my environment looks like this:
jinja2 3.1.2
matplotlib 3.5.2
numpy 1.23.3
pandas 1.3.5
tensorboard 2.10.1
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.10.0
tensorflow-base 2.10.0
tensorflow-deps 2.8.0
tensorflow-estimator 2.10.0
tensorflow-macos 2.10.0
tensorflow-metal 0.6.0
tensorflow-probability 0.18.0
tfcausalimpact 0.0.12
To check that tensorflow was working as expected, I trained a simple neural network on some toy data and everything worked fine.
However, when I try to run this part of the example code
ci = CausalImpact(data, pre_period, post_period)
my kernel crashes - I'm using a notebook within VS Code.
This is the error message, which points towards this article - https://github.com/microsoft/vscode-jupyter/wiki/Kernel-crashes. But unfortunately, nothing that I've tried there seems to work.
Canceled future for execute_request message before replies were done The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. View Jupyter [log](command:jupyter.viewOutput) for further details.
And the output from the VS Code console.
warn 11:26:07.435: StdErr from Kernel Process /Users/kaimajerus/miniforge3/envs/causal_impact/lib/python3.8/site-packages/traitlets/traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '4fb728c4-adc1-4a75-a4c0-698a446dbfef' instead of 'b"4fb728c4-adc1-4a75-a4c0-698a446dbfef"'.
warn(
info 11:26:07.440: Kernel Output: To connect another client to this kernel, use: --existing kernel-v2-97179Bb34ZVzN3GWL.json
info 11:26:07.655: Started Kernel causal_impact (Python 3.8.13) (pid: 97392)
info 11:26:07.660: UpdateWorkingDirectoryAndPath in Kernel
error 11:26:07.942: Failed to get activated conda env variables from Python for /Users/kaimajerus/miniforge3/envs/causal_impact/bin/python
info 11:26:07.942: Got empty env vars with python /Users/kaimajerus/miniforge3/envs/causal_impact/bin/python in 194ms
info 11:26:07.943: Process Execution: > ~/miniforge3/envs/causal_impact/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/pythonFiles/printJupyterDataDir.py
> ~/miniforge3/envs/causal_impact/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/pythonFiles/printJupyterDataDir.py
warn 11:26:07.959: Got a non-existent Jupyer Data Dir file:///Users/kaimajerus/.local/share/jupyter
info 11:26:33.540: Kernel Output: To connect another client to this kernel, use: --existing kernel-v2-97179Bb34ZVzN3GWL.json`
`Metal device set to: Apple M1 Max
systemMemory: 64.00 GB
maxCacheSize: 24.00 GB
warn 11:26:33.546: StdErr from Kernel Process 2022-10-11 11:26:33.524077: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2022-10-11 11:26:33.524234: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
warn 11:26:34.605: StdErr from Kernel Process 2022-10-11 11:26:34.604572: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
warn 11:26:34.850: StdErr from Kernel Process 2022-10-11 11:26:34.850395: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
warn 11:26:39.231: StdErr from Kernel Process 2022-10-11 11:26:39.230775: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
warn 11:26:47.004: StdErr from Kernel Process 2022-10-11 11:26:47.003509: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
error 11:26:50.307: Disposing session as kernel process died ExitCode: undefined, Reason: /Users/kaimajerus/miniforge3/envs/causal_impact/lib/python3.8/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
warn(
/Users/kaimajerus/miniforge3/envs/causal_impact/lib/python3.8/site-packages/traitlets/traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '4fb728c4-adc1-4a75-a4c0-698a446dbfef' instead of 'b"4fb728c4-adc1-4a75-a4c0-698a446dbfef"'.
warn(
2022-10-11 11:26:33.524077: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2022-10-11 11:26:33.524234: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
2022-10-11 11:26:34.604572: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
2022-10-11 11:26:34.850395: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
2022-10-11 11:26:39.230775: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
2022-10-11 11:26:47.003509: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.`
`info 11:26:50.308: Dispose Kernel process 97392.
error 11:26:50.309: Raw kernel process exited code: undefined
error 11:26:50.313: Error in waiting for cell to complete [Error: Canceled future for execute_request message before replies were done
at t.KernelShellFutureHandler.dispose (/Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:32353)
at /Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:51405
at Map.forEach (<anonymous>)
at y._clearKernelState (/Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:51390)
at y.dispose (/Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:44872)
at /Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:2215299
at t.swallowExceptions (/Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:7:130890)
at p.dispose (/Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:2215277)
at t.RawSession.dispose (/Users/kaimajerus/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002791758/out/extension.node.js:2:2220385)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)]
warn 11:26:50.314: Cell completed with errors {
message: 'Canceled future for execute_request message before replies were done
}
info 11:26:50.316: Cancel all remaining cells true || Error || undefined
Full set of commands that I ran:
conda create --name causal_impact python=3.8
conda activate causal_impact
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
conda install tensorflow
conda install matplotlib
pip install pandas==1.3.5
pip install tensorflow_probability==0.18.0
pip install tfcausalimpact
conda install ipykernel
pip uninstall numpy
pip install numpy
pip install numpy --upgrade
hi @kmajerus-upp ,
Reading through the traceback I couldn't identify what could be the issue. Just wondering, if you run the same code in a vanilla python/ipython environment does it raise the same issue?
Hi @WillianFuks - yes it raised the same issue, although it was a bit clearer. The last few lines of the trace were:
2022-10-11 21:31:50.202322: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
2022-10-11 21:31:50.233309: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
2022-10-11 21:31:53.109627: F tensorflow/core/framework/tensor.cc:728] Check failed: IsAligned() ptr = 0x287d93030
Which led me to this thread. Could potentially be an issue with tensorflow-metal. The most recent comment in the thread is from someone having the same problem with tfcausalimpact
.
Edit: I created a new environment and did exactly the same as before, but without installing tensorflow-metal. The kernel no longer crashes when running the example code.
conda create --name causal_impact python=3.8
conda activate causal_impact
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
conda install tensorflow
conda install matplotlib
pip install pandas==1.3.5
pip install tensorflow_probability==0.18.0
pip install tfcausalimpact
conda install ipykernel
Just wondering, if you run your code inside an ubuntu based docker image does it work? What line of tfcausal raises the exception?
I successfully downloaded TensorFlow and TensorFlow probability on M1 12.0 macOS into a Conda environment. When pip installing ufcausalimpact into the environment I get the following error. Note: I can successfully import TensorFlow within the Conda environment's python. I installed TensorFlow following these instructions. I installed python 3.8.10 using pyenv.