Python (PyCharm) and Fenics - Installation Problems - python

I’ve tried to install fenics and use the repository of the paper “Hybrid FEM-NN models: Combining artificial neural networks with the finite element method]” to calculate a linear Physics-Informed Neural Network for a linear problem (https://github.com/sebastkm/hybrid-fem-nn-examples/tree/main/examples/pinn_linear).
I’m using Windows 11 and Python 3.10.4.
To run the script main.py I need to use the fenics package. As usual working in python I did
pip install fenics
which worked without any problems. Trying to run the script prompted the error
from fenics import *
ModuleNotFoundError: No module named 'fenics'
After reading a couple of posts on this issue I made sure there are no other virtual environments anymore and that the path sys.path :
C:\Users\neuma\AppData\Local\Programs\Python\Python310\Lib\site-packages
contains the folder which contains the installed fenics packages:
fenics_dijitso-2019.1.0.dist-info
fenics_ffc-2019.1.0.post0.dist-info
fenics_fiat-2019.1.0.dist-info
fenics_ufl-2019.1.0.dist-info
fenics-2019.1.0.dist-info
I’ve noted that there is no folder named just fenics.
After this attempt did not work I tried to follow the instruction for DOLFINx (https://docs.fenicsproject.org/dolfinx/main/python/installation.html#dependencies) since some posts mentioned dolfinx and fenics are the same.
After installing the docker I followed the instructions on running fenics within the docker (https://fenics.readthedocs.io/projects/containers/en/latest/introduction.html#installing-docker). This at least seemed to work using the Terminal:
C:\Users\neuma>docker run -ti quay.io/fenicsproject/stable:latest
# FEniCS stable version image
Welcome to FEniCS/stable!
This image provides a full-featured and optimized build of the stable
release of FEniCS.
To help you get started this image contains a number of demo
programs. Explore the demos by entering the 'demo' directory, for
example:
cd ~/demo/python/documented/poisson
python3 demo_poisson.py
fenics#9548d966c2fc:~$ cd ~/demo/python/documented/poisson
fenics#9548d966c2fc:~/demo/python/documented/poisson$ python3 demo_poisson.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving linear variational problem.
To view figure, visit http://0.0.0.0:8000
Press Ctrl+C to stop WebAgg server
Visiting the url prompt the following message:
This page is not working
0.0.0.0 has not sent any data.
ERR_EMPTY_RESPONSE
Since I seem to have tried all possible versions of installation of fenics (and/or Dolfinx) and nothing worked I want to ask here if anyone could help me with the installtion.
I’m pretty confused about how to understand the difference betweend fenics and dolfinx and why I need Ubuntu or Linux and a Docker to run a package which already seems to be installed in python . Maybe this screenshot will make it a little clearer:
If you need any more information just let me know. Would be great if someone could help me out.
Oskar

In case anyone else struggles with this or similiar problems, the solution was given here: https://fenicsproject.discourse.group/t/installation-problems/9041/43

Related

Cant use ipynb files on jupyter/vsc

its my first post so do tell me if you require more specifics.
some details may not be too relevant here but i want to give to be as detailed as possible with the timeline here:
I have been using jupyter for my ipynb files for quite some time until i discovered tensorflow, at first it was going ok after installing the module but ever since i tried to use tensorflow to detect and utilise my gpu everything just went south from there. i tried things like downloading some nvidia stuff that my laptop does in fact support, and eventually got my tensorflow to detect my gpu. But the moment i tried to train my model with cnn, however simple the layers are, my kernel will crash. Eventually i used kaggle/colab as temporary solution but now i want to fix it.
After trying to fix the issue of tensorflow/revert back to when tensorflow runs just fine with only my cpu to no avail, i eventually decided to do a hard reset and deleted python/anaconda entirely from my computer.
After installing anaconda back. I booted up jupyter to see that there is a python3 ipykernel that is most likely preinstalled when i downloaded anaconda and i can run a simple hello world just fine. However i realise that after pip installing tensorflow my 'old' settings of tensorflow is still there and can detect my gpu, and hence kernel will crash yet again.
So, i thought why not just make a completely new environment so i can 100% install a new and fresh version of tensorflow. Then i realised that jupyter couldnt exactly detect the new environment that i made (idk if its cause of ipykernel but i did do a pip install ipykernel in the correct environment and its still not detected).
My next solution was to try to use vsc, so i used vsc and managed to detect the new environment but when running a print('hello world') i was told that 'The kernel failed to start as a dll could not be loaded. View Jupyter log for further details.'
I'm really lost as to what to do now, all i want to do at this point of time is to use tensorflow (whether cpu or gpu i rlly dont care anymore) in either vsc/jupyter. As long as my files are .py, i should be able to run it with any environment just fine ( though i didnt test with tensorflow module on py files because i dont see a point in training a model on a py file)
I use windows 10 if that helps
Im sorry if i gave unneccessary details. I would appreciate if i get some advice in anything im doing wrong/have a misunderstanding of/solutions and please do try to dumb it down for me with appropriate explanations if possible... thanks...... i can also be contacted on a voice call in discord if you think typing it is too much of a hassle

How to install tensorflow on a raspberry pi 4 running Manjaro

I am trying to get tensorflow installed on a raspberry pi 4 which is running manjaro. It is to use the open source BNN library Larq, which recommended manjaro as an OS because it was 64bit as opposed to Raspbian. I have tried to install using yay from Archlinux user repository but got a couple different errors, like: "tensorflow/workspace.bzl: patch does not apply" and a failure to download. Any suggestions, I am very new to manjaro.
As a side note, I am not particularly stuck to Manjaro is anyone has experience using Larq and the larq compute engine on a RPi4 with a different OS any insight there would be helpful as well.
Thank you!
I cannot help you with Manjaro. However, I used Ubuntu 20.04 (64 bits) on my RPI4. I suppose you need the RPI4 to deploy and run your BNNs. If I am correct, I give you the following advice.
Please, note that the RPI4 is needed only to run LCE models (*.tflite). To this end, you don't need to install Tensorflow on your RPI4.
For everything else (see below) you can use a regular Linux box.
To check if everything is fine with your runtime environment (i.e. the RPI4), You can use your main Larq+LCE installation to convert one of your models into an LCE model and test it with the benchmark tool available here. For the RPI4+Ubuntu you should use lce_benchmark_model_aarch64.
If you need to compile your own BNN-based applications for your RPI4, you can follow the build guide on the LCE website. I did it once a long time ago. I used the LCE Docker to have a working environment. Then, from the inside of the docker, I followed the ARM guide: "Cross-compiling with Make" version.
I hope this helps.

Anaconda install, basic usage issues

everyone. I installed anaconda to use python and install ai packages. I am new to high-level computer use beyond the normal GUI that windows has blessed us with.
Background: I am just starting using command prompts and am teaching myself python to use for ai with keras and tensorflow. Unfortunately, I cannot get far enough to install these packages because after I install anaconda, I get multiple errors in the command prompt. Access Denied was solved by installing for all users and running as administrator. However, I cannot use conda, and when I use pip, I get constant html errors. Nothing works. I tried adding \Anaconda3 and \Anaconda3\Scripts to PATH, but it doesn't change anything. The prompt starts by telling me that it cannot find the specified paths then kicks me over to C:\Windows\system32, but when I cd back to my \Anaconda3 directory, nothing changes. What am I doing wrong? What do I need to try?
I appreciate it. As basic as this is, rest assured I spent days struggling with this before posting.

Test Anaconda build after updating packages

I use conda update --all to update my packages. Recently, I encountered an error with Anaconda build, posted at Error while trying to update and use scipy module in Anaconda. It seems now the issue has been fixed. Is there any way, I can test all modules one by one by importing them and deleting them ? I am requesting this because I have noticed that if import doesn't work, I spend a lot of time figuring out the dependency and then the package that is causing this. For instance, a few minutes ago I found that PyCharm 2018.2.4 breaks with the latest version of matplotlib (3.0.0). Hence, it might be helpful to run some type of test script after running conda update --all to ensure that all packages are indeed working--i.e. importable.
I did some research on this topic and found three sources.
First, Anaconda offers run_test.py (Source: https://conda.io/docs/user-guide/tasks/build-packages/recipe.html). However, being new to the world of Python, I am unsure how to go about running a script in Anaconda terminal.
Second, I found: https://conda.io/docs/user-guide/install/test-installation.html. However, this just tells me the version of the package. I am not interested in the version. I need to know whether all packages import properly.
Finally, I found out that there is a method to run test script for all packages at https://anaconda-installer.readthedocs.io/en/latest/testing.html. However, I am unsure how I can run make in Anaconda terminal. I used to use make long time ago when I worked on gcc on Unix environment. Being new to Python, I am unsure how to go about handling this.
I'd appreciate any thoughts or any test script that could help us verify two things:
a) whether all packages have been installed
b) packages are indeed importable; If the package import fails, the script should terminate with handsome error message highlighting the source (package) where import failed.

Problems building node.js on Cygwin, please help

I'm trying to get node.js running on Windows 7. I have no experience with Linux so I've just been blindly following instructions from tutorials I've found, but I'm still unable to build node.js.
What I did:
Install Cygwin - the entirety
Attempt to build node.js
This is the error I first got:
I then followed the commands of two other similar sites and they all resulted in this error (could getting several version of node have caused me more problems? I'm completely clueless on this).
I read somewhere that the Windows version of Python could be causing the problem so I uninstalled my Python 2.7 and added C:\cygwin\bin to the PATH.
That still didn't work and I read somewhere else that I'm supposed to rebaseall so I tried that, but I also got an error for that:
That's where I'm at now. Have any steps I've taken exacerbated the situation?
Add -e '/\/sys-root\/mingw\/bin/d' at line 110 in /bin/rebaseall file.
Then re-run rebaseall -v and you shouldn't get the error anymore.
See this pretty helpful blog posting - Node on CygWin doesn't work for Node v0.2.5. Use the latest v0.4.0 version instead.
Also consider the post's recommendation of compiling against MinGW instead of in CygWin.
First of all, why did you check out such an old release v0.2.5? When I did it a few weeks ago I just took the latest and ended up with 0.5.0pre, but it would also be reasonable to specify v0.4.3. For instance, type git clone git://github.com/joyent/node.git to download node, and then:
cd node
./configure
make install
Secondly, do not rebase by running ash from the CYGWIN shell. Instead, shutdown all Cygwin processes, then use Windows explorer to open the ash.exe binary. Since I have a Windows 7 system without node.js, I decided to follow my instructions and build. Not so easy. I ran into some wierd dll issues that all went away when I ran ./rebaseall followed by ./perlrebase from the ash prompt. It seems that rebaseall is not sufficient anymore.
Thirdly, there is a message that makes it sound like you don't have a C compiler. Some googling will lead you to sites telling which Cygwin packages you need, but at minimum install the g++ compiler and that should pull in C as a dependency.
When I did this I simply ran configure and every time there was an error, installed one more Cygwin package to supply the missing piece. Even OpenSSL is available.
What I just found is remove the windows based install of Python. After uninstalling this, everything is peachy.
I like cygwin a lot -- but recent releases have become pretty unreliable. Some packages just wont build, and some "standard" apps dont work e.g. gvim's "save as" bombs out on my installation.
A possible solution would be run one of the better Linux distributions (ubuntu, fedora, suse etc.) either as a virtual machine or a dual boot setup and do the build inside linux.

Categories

Resources