I am trying to use the cv2.FastFeatureDetector() method and everytime i run this code to extract features my kernel in both Google Collab and Anaconda crashes for some reason. Initially I thought it was memory management issue with my system, but the same thing is happening in Colab.
import cv2
import numpy as np
image=cv2.imread('tree.jpg',0)
fast=cv2.FastFeatureDetector()
keypoints=fast.detect(image,None)
#After running this code my kernel crashes
There is no error message due to the kernel crash.
The image is fairly small in size and not that computationally expensive.
Here is the image:
https://www.setaswall.com/wp-content/uploads/2017/06/Sun-Tree-Branches-1920-x-1080.jpg
I had the same problem. With newer OpenCV versions you have to create your detector via fast = cv2.FastFeatureDetector_create(). Note that you might have to adjust the rest of your code due to other API changes.
Related
Is there an automatic way to check which GPU is currently available on Google Colab (Pro).
Say I would like to use a Tesla P100 instead of the Tesla T4 to train my model, is there a way to periodically check with a python script in Colab whether the P100 is available?
I have tried eliminate the kernel periodically but it won't restart again automatically after shutting down:
import os
def restart_runtime():
os.kill(os.getpid(), 9)
Thank you
There is no way to check what GPU is available. Add the line:
!nvidia-smi
to the beginning of your code and then keep on disconnecting and reconnecting the runtime until you get the GPU that you want.
I met this issue when I running my python file in linux.
I searched some answers in google like use the code below:
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
The system can be running but without ant out information. Actually I found the 2 measn ignore all information while 1 means give all information like error or normal output.
because I need to use GPU so my original code is:
os.environ["CUDA_VISIBLE_DEVICES"]="0"
But if I keep the code my output would be an error information like the title.
How can I do? and of course I need use the GPU and the codes can be running in colab which indicated that my code has no problem.
some guys even said uninstall tensorboard...that must a wrong way.
Or should I download tensorflow gpu not tensorflow in m,y virtual enviroment? when I USE THE tensorflow gpu version, the error is core dumped.
If when forcing the os.environ["CUDA_VISIBLE_DEVICES"]="0" doesn't work, then this means that your tensorflow gpu installation did not succeed. You must ensure you have the right combination of TensorFlow + CUDA + CUDNN. That is why you get the error, because due to improper versions/installation TF falls back on CPU.
I am trying to free memory in between Optuna optimization runs. I am using python 3.8 and the latest version of Optuna. What happens is I run the commands: optuna.create_study(), then I call optuna.optimize(...) in a loop, with a new objective function each time. When I monitor my memory usage, each time the command optuna.create_study() is called, memory usage keeps on increasing to the point that my processor just kills the program eventually. Just for a more clear picture, the first run takes over 3% memory and it eventually builds up to >80%. Any thoughts on how I can remove a study from memory in between successive calls of create_study()?
I had a similar problem working with pytorch. Following the optuna docs https://optuna.readthedocs.io/en/stable/faq.html#how-do-i-avoid-running-out-of-memory-oom-when-optimizing-studies , I tried with this solution:
study.optimize(objective, n_trials=n_trials, gc_after_trial=True)
which should be similar to
import gc
study.optimize(objective, n_trials=n_trials, callbacks=[lambda study, trial: gc.collect()])
However, none of them worked for me. The only way I could fix it was just by upgrading the pytorch version to the newest one. I do not know if you are using pytorch or other ML packages maybe, but you may need to update the appropriate packages in case the above lines do not work.
I had a similar problem when running my trial (although I did not loop over multiple optimizations). Creating a callback that frees garbage at the end of each epoch solved my problem and will probably already help you free quite some space. Try the following:
import tensorflow as tf
import gc
class MyCustomCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs=None):
gc.collect()
...
_ = model.fit(x_train, y_train, ...
callbacks=[MyCustomCallback()])```
Solution based on this issue.
Currently trying to run a basic similarity search via FAISS with reproducible code from that link. However, every time I run the code in the following venues, I have these problems:
Jupyter notebook - kernel crashes
VS Code - receive "Illegal Instruction" message in the terminal with no further documentation
I've got similar code working in Kaggle, so I suppose the problem is with my particular setup.
Based on the print statements, it appears that the error occurs during the call of the .search method. Because of how vague this error is, I've not been able to find much information on the problem. It seems that some people mentioned older processors may have a problem (AVX/AVX2 flags being the culprit?), though admittedly I didn't quite understand the connections.
Problem: Can I get some help understanding this error, and if possible, a potential solution?
Current setup:
WSL2
VSCODE (v. 1.49.0)
Jupyter-client (v. 6.1.7)
Jupyter-core (v. 4.6.3)
FAISS-cpu (v. 1.6.3)
Numpy (v. 1.19.2)
Older machine (AMD FX-8350 with 16GB RAM)
For anyone that runs across this error, the problem (in my case) was that my CPU was old enough that it doesn't support AVX2. To determine this, I used this SO post.
Once I ran the code in Colab or on a newer machine, all was well.
I am doing video processing on beagleboard-xm with ubuntu installed in it. Ubuntu is with complete GUI but it is prebuilt image for omap3.Libraries used for these project is OpenCV.
So, the problem is whole process is too slow.Is there a way to fasten up the process like removing GUI? or removing unwanted packages?or installing of some optimized OS
You can try Ångström Distribution for Beagleboard may be faster than Ubntu.