Python: Difference between revisions

From Utopia
Jump to navigation Jump to search
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:


== GPU AI Programmierung ==




== Web Programmierung ==
Was benötigt man, um mit einer NVIDIA GTX 1660 TI GPU-Programmierung zu tun?


=== WSGI ===
* cuDNN
* CUDA Toolkit
** benoetigt Visual Studio
* Python
* Tensorflow


Installation von cuDNN


* installiere cuda
* check Windows Environment Variable wo Cuda hin installiert wurde
* Wenn cuda nicht im environment, setze sowas wie:
** CUDA_PATH — -> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0
** CUDA_PATH_V11_0 — → C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0
* kopiere das cuDNN/bin verzeichnis in das bin verzeichnis von cuda... ebenso include nach include... libs nach libs...
* fuege eine CUDNN variable im windows environment hinzu "...cuda/.../bin;...cuda/.../lib;....cuda/...include
* hau die pfade zusaetzlich in die PATH variable<br />


apt-get install libapache2-mod-wsgi-py3
Tensorflow


a2enmod wsgi
* ist kompatibel mit Python 3.8 - 3.11
* ist kompatibel mit Windows 7 oder hoeher
* Tensorflow 2 benoetigt pip version > 19.0


=== Apache2 ===


==== Benoetigte Apache Module ====
<code>libapache2-mod-python</code>


* Python-embedding module for Apache 2
== IDE ==


==== Optionale Apache Module ====
[[PyCharm]]


libapache2-mod-python-doc
== Libarys ==


* Python-embedding module for Apache 2 - documentation<br />
=== os ===


import os


Datei einlesen


==== Apache Fehler ====
with open(fileName) as f:


[[Apache2 Errors]]
    lines = f.readlines()


'''<u><big>Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration</big></u>'''


== Web Programmierung ==






<u>gucken ob die Datei da ist:</u>
[[WSGI]]
 
 
 
cat mods-available/python.load
 
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
 
 
 
<u>gucken ob die .so da ist:</u>
 
 
 
 
'''ll /usr/lib/apache2/modules/mod_python.so'''
 
-rw-r--r-- 1 root root 143K Jun 28  2013 /usr/lib/apache2/modules/mod_python.so
 
 
<u>Bei mir war die Zeile "LoadModule" komischerweise auskommentiert. Wenn ich sie wieder einkommentiere, dann startet Apache2 nicht mehr, ohne Fehlermeldung. Er sagt einfach</u>
 
'''service apache2 restart'''
 
Job for apache2.service failed because the control process exited with error code.
 
See "systemctl status apache2.service" and "journalctl -xe" for details.
 
 
'''systemctl status apache2.service'''
 
apache2.service - The Apache HTTP Server
 
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
 
Active: failed (Result: exit-code) since Sat 2023-05-06 17:03:31 CEST; 7s ago
 
Docs: <nowiki>https://httpd.apache.org/docs/2.4/</nowiki>
 
Process: 21674 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
 
systemd[1]: Starting The Apache HTTP Server...
 
apachectl[21674]: Action 'start' failed.
 
apachectl[21674]: The Apache error log may have more information.
 
systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
 
systemd[1]: apache2.service: Failed with result 'exit-code'.
 
[systemd[1]: Failed to start The Apache HTTP Server.
 
 
 
<u>Die error.log von Apache2 meinte daraufhin:</u>
 
 
'''tail -n 100 /var/log/apache2/error.log'''
 
[wsgi:crit] [pid 21542] mod_wsgi (pid=21542): The mod_python module can not be used in conjunction with mod_wsgi 4.0+. Remove the mod_python module from the Apache configuration.
 
AH00016: Configuration Failed
 
 
Problem herausgefunden:
 
mod_wsgi und mod_python arbeiten in der aktuellen Version nicht mehr zusammen. Es gab irgendwie Probleme mit dem Thread-Management der C-Lib... Die Lösung soll ein
 
Zitat: "...you shouldn't be using mod_python any more. Use a proper Python web framework with a more modern template system instead."
 
 
Wikipedia sagt dazu:
 
"Eine konzeptionelle Weiterentwicklung von mod_python ist mod_wsgi."
 
 
Also erstmal das mod_python ausradieren... :)
 
'''apt-get purge <code>libapache2-mod-python libapache2-mod-python-doc</code>'''
 
 
dann die apache2 config meiner Seite anpassen:
 
Laut des Quick Configuration Guides https://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html einfach nen Skript-Alias einbauen
 
 
'''vi /etc/apache2/sites-available/subdomain.domain.tld'''
 
 
<VirtualHost *:80>
 
  ServerName subdomain.domain.tld
 
  ServerAlias domain.tld  *.domain.tld
 
  DocumentRoot /var/www/subdomain.domain.tld
 
  WSGIScriptAlias / /var/www/subdomain.domain.tld /index.wsgi
 
</VirtualHost>
 
 
Apache neu starten


'''service apache2 restart'''




und TADAAAAAAA... :)
[[Django]]

Latest revision as of 20:04, 12 September 2023

GPU AI Programmierung

Was benötigt man, um mit einer NVIDIA GTX 1660 TI GPU-Programmierung zu tun?

  • cuDNN
  • CUDA Toolkit
    • benoetigt Visual Studio
  • Python
  • Tensorflow

Installation von cuDNN

  • installiere cuda
  • check Windows Environment Variable wo Cuda hin installiert wurde
  • Wenn cuda nicht im environment, setze sowas wie:
    • CUDA_PATH — -> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0
    • CUDA_PATH_V11_0 — → C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0
  • kopiere das cuDNN/bin verzeichnis in das bin verzeichnis von cuda... ebenso include nach include... libs nach libs...
  • fuege eine CUDNN variable im windows environment hinzu "...cuda/.../bin;...cuda/.../lib;....cuda/...include
  • hau die pfade zusaetzlich in die PATH variable

Tensorflow

  • ist kompatibel mit Python 3.8 - 3.11
  • ist kompatibel mit Windows 7 oder hoeher
  • Tensorflow 2 benoetigt pip version > 19.0


IDE

PyCharm

Libarys

os

import os

Datei einlesen

with open(fileName) as f:
    lines = f.readlines()


Web Programmierung

WSGI


Django