Darkflow without GPU on Jupyter-Notebook - Simple Code Required - jupyter-notebook

I am unable to setup & run a simple darkflow program. Infact can't even configure darkflow library:
from darkflow.net.build import TFNet
==> ModuleNotFoundError: No module named 'darkflow'
My Target is to run the following program:
from darkflow.net.build import TFNet
import cv2
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
tfnet = TFNet(options)
imgcv = cv2.imread("./test/dog.jpg")
result = tfnet.return_predict(imgcv)
print(result
Please suggest steps so that I could configure darkflow on Jupyter Notebook (with no GPU) and run the above code

Fixed by creating the file in ipynb file in darkflow directory (downloaded from github) and executing the following from the notebook:
!python3 setup.py build_ext --inplace
!pip install -e .
!pip install .

Related

Script in mpi4py not executing correctly

I'm developing a cluster using mpi4py and when i run a basic script to test the cluster the result is weird:
the result should be this (script executed in c):
My code:
from mpi4py import MPI
world_comm = MPI.COMM_WORLD
world_size = world_comm.Get_size()
name = MPI.Get_processor_name()
my_rank = world_comm.Get_rank()
print('World Size: {0} | Name: {1} | Rank: {2}'.format(world_size,name,my_rank))
And the hostfile:
no02 slots=3
no01 slots=5
How could I get around this problem?
I managed to solve it as follows: I reinstalled mpi4py, but this time I passed the MPICC env before installation:
env MPICC=/usr/bin/mpicc pip3 install mpi4py --no-cache-dir
But you need to make sure the libopenmpi-dev library is installed and then run the which mpicc command and put it as a path in the env in the above command

Failed to execute script due to unhandled exception: No module named ttkwidgets

I created an executable from a py file that used ttkwidgets
import tkinter as tk
import work_logger_database
from ttkwidgets.autocomplete import AutocompleteEntry
root = tk.Tk()
root.geometry('600x300')
items = work_logger_database.show_all()
stored_projects_list = list(set([items[i][2] for i in range(len(items))]))
#or:
#example_list = ['Hello', 'World']
project_entry = AutocompleteEntry(root, completevalues=stored_projects_list)
project_entry.grid(column=0, row=1, sticky='W')
root.mainloop()
and when I open the exe I get what is shown in this image
I also got a warning:
WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
I'm not sure if that's relevant
I tried a solution in creating the exe that didn't work:
pyinstaller work_logger.py --onefile -w --hidden-import=ttkwidgets --hidden-import=ttkwidgets.autocomplete
I also tried:
pyinstaller work_logger.py --onefile -w --hidden-import=ttkwidgets
Had the same ModuleNotFoundError: 'ttkwidgets' creating an executable of one of my scripts.
Worked after (re-)installing ttkwidgets on my system:
pip install ttkwidgets

Nbgrader with Littlest JupyterHub releases assignment to course directory but not to /srv/nbgrader/exchange

Operating system
nbgrader --version: 0.6.1
jupyterhub --version (if used with JupyterHub): 1.0.0 (Using littlest Jupterhub)
jupyter notebook --version
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : 4.7.2
ipython : 7.13.0
ipykernel : 5.2.0
jupyter client : 6.1.2
jupyter lab : 1.2.8
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.4
traitlets : 4.3.3
Expected behavior: When used
nbgrader release_assignment ps1 --force --debug
It should release the assignment in /srv/nbgrader/exchange shared folder.
Actual behavior
I am facing an issue when I try to release the assignment:
nbgrader release_assignment ps1 --force --debug
It releases the assignment without errors but to the location (/home/jupyter-tljh-admin/course_id/outbound/ps1) but not to the shared location /srv/nbgrader/exchange:
[ReleaseAssignmentApp | INFO] Overwriting files: /home/jupyter-tljh-admin/course_id ps1
[ReleaseAssignmentApp | INFO] Source: /home/jupyter-tljh-admin/course_id/release/./ps1
[ReleaseAssignmentApp | INFO] Destination: /home/jupyter-tljh-admin/course_id/outbound/ps1
[ReleaseAssignmentApp | INFO] Released as: /home/jupyter-tljh-admin/course_id ps1
The folder /srv/nbgrader/exchange has write permissions.
Please suggest, what could be the issue?
I faced a similar problem. When I opened the Formgrader there was a notification saying that the directory /srv/nbgrader/exchange does not exist or could not be created. I simply created the directory on my own, but not directly. First I created the directory /srv/nbgrader with sudo. Then I cd into that directory and created the subdirectory exchange, also with sudo. I also added a nbgrader_config.py in /etc/jupyter with the following content:
from nbgrader.auth import JupyterHubAuthPlugin
c = get_config()
c.Exchange.path_includes_course = True
c.Authenticator.plugin_class = JupyterHubAuthPlugin
This solved the issue for me.
Create the /srv/nbgrader/exchange directory and add the permissions like this: chmod ugo+rw /srv/nbgrader/exchange
Open the nbgrader_config.py that was created after running nbgrader quickstart <course-id>
Make sure these two lines are present and uncommented:
c.CourseDirectory.course_id = "<course-id>"
c.IncludeHeaderFooter.header = "source/header.ipynb"
Search for the specific line that says: c.CourseDirectory.root = '', uncomment it, and set it to c.CourseDirectory.root = /full/path/to/your/course-id/
Search for the specific line that says: c.Exchange.assignment_dir = '.' and actually set it to c.Exchange.assignment_dir = '/srv/nbgrader/exchange'
Copy this exact nbgrader_config.py into .jupyter or any other directory that apprear in jupyter --paths
Stop and restart your server

How to resolve: ImportError: cannot import name 'HttpNtlmAuth' in python3 script?

I have installed both requests and requests_ntlm modules using "sudo python3 -m pip install requests" (and requests_ntlm respectively) and both installs were successful.
When I then attempt to do "from requests import HttpNtlmAuth", I get an error stating "cannot import name 'HttpNtlmAuth'. I do not get this error on my "import requests" line.
When I do a "sudo python3 -m pip list", I see both are installed and are the latest versions.
I've not encountered this error before, only "cannot import module", so I'm unfamiliar with how to resolve this.
EDIT 1: Additional information. When I run this script from command line as "sudo", it works. Because I am running my python script from within a PHP file using "exec", I don't particularly want to run this as a root user. Is there a way around this, or possibly running the exec statement with sudo?
the HttpNtlmAuth class is in the requests_ntlm package so you'll need to have:
import requests
from requests_ntlm import HttpNtlmAuth
Then you'll be able to instantiate your authentication
session = requests.Session()
session.auth = HttpNtlmAuth('domain\\username','password')
session.get(url)

Python/R ctypes library error: "OSError: lib/libRrefblas.so: undefined symbol: xerbla_"

Firstly, I'm a newbie R, AWS and python guy. So I'm trying to get a python script with embedded R code running in AWS Lambda using rpy2. I created a Lambda package on an EC2 instance following the instructions here (modified for using python 3.4). It seems that there is something funky happening with loading the R libs using ctypes, as per the following error received in the console:
OSError: lib/libRrefblas.so: undefined symbol: xerbla_
The test file (py_test.py) looks like this:
import os
import ctypes
for file in os.listdir('lib'):
if os.path.isfile(os.path.join('lib', file)):
ctypes.cdll.LoadLibrary(os.path.join('lib', file))
os.environ["R_HOME"] = os.getcwd()
os.environ["R_USER"] = os.path.join(os.getcwd(), 'rpy2')
os.environ["R_LIBS"] = os.path.join(os.getcwd(), 'library')
os.environ["LD_LIBRARY_PATH"] = os.path.join(os.getcwd(), 'lib')
import sys
sys.path.append(os.path.join(os.getcwd(),'rpy2'))
import rpy2
from rpy2 import robjects
def test_handler(event, context):
robjects.r('''
f <- function(r, verbose=FALSE) {
if (verbose) {
cat("I am calling f().\n")
}
2 * pi * r
}
print(f(3))
''')
test_handler(None,None)
I have lib/libRrefblas.so in my virtual environment. I have scoured google looking for answers but have come up empty. Any suggestions would be greatly appreciated!
If you can get the traceback, that could help, but I suspect the problem is that it's looking for xerbla_ in the wrong place. Is xerbla_ defined in the path to RLIBS? Maybe in libR.so?
Turns out the BLAS that ships with R is corrupt. Your best bet is to make sure that BLAS and Lapack are installed on the machine you are building R on and see if you can get it to build with those libraries instead.
So steps would be to uninstall R, then run
yum -y install lapack-devel.x86_64 lapack.x86_64
yum -y install blas -devel
yum -y install R.x86_64
Check to see if it has still installed with libRrefblas.so. If it has - try deleting that file and see if it will default to the system BLAS. If you get a error because it is still looking for libRrefblas.so
rm lib/libRrefblas.so
cp /usr/lib64/libblas.so.3 lib/
mv lib/libblas.so.3 lib/libRrefblas.so

Resources