好多的鱼


  • Home

  • Archives

为一块交换机板卡打通音频驱动

Posted on 2024-01-25

隔壁组做了一块板子,从某交换机环境改的,加了一个usb音频设备,申请我支援打通这个设备。连上去一看,设备已经识别为TI 2903,但是dev/snd下面只有个timer。编译内核一看,版本很老,没有alsa?打开了OSS选项,重新编译之后,出现了control设备和PCM设备,这是最原始的波形接口。
apt-get install alsa-base alsa-utils pulseaudio

然后重启alsa
alsa force-reload
提示:

Unloading ALSA sound driver modules:.
Loading ALSA sound driver modules: (none to reload).
看来还是需要alsa驱动的,回头去内核里找。
原来alsa在内核里叫Device Drivers -> Sound card support -> Advanced Linux Sound Architecture。把所有的模块都启动了。
使用aplay xxx.wav 测试,正常输出音频。

mint系统下搜狗拼音出错调试

Posted on 2023-12-02

搜狗拼音

因为工作需要,新装了一个linux系统,选了mint 20.01,安装完之后,安装了vscode和搜狗拼音,搜狗拼音切换后,能够看到图标栏改变,但是没有输入框。全角标点可以输出,无法输入中文。
干掉输入法管理程序后手动启动

1
2
3
killall fcitx
fcitx

发现报错libQtxxx no version information available.看来是Qt库状态不对,导致输入法界面切不出来。
重新安装qt无效。
仔细看看,原来搜狗自己带了一个qt库,放在/opt/sougoupingyin/files/lib/qt5/lib下面。从系统目录/usr/lib/x86_64-linux-gnu/拷贝所有qt库到这个目录下,重新启动输入法,顺利输入中文。

远程呈现的小火车

Posted on 2023-10-25

小火车 示例

Three.js 示例

Posted on 2023-10-25

Three.js 示例

将python打包为exe

Posted on 2023-10-25

最近和结构的同事一起玩three.js,做了一个简易的展示,先启动一个python的http server,然后通过浏览器访问httpserver来呈现3D图像。在操作中,发现同事对命令行启动python非常不习惯,于是将python的.py文件打包为exe,只要放在文件夹下,双击即可执行。
python服务器代码用AI生成如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import http.server
import socketserver
from http.server import SimpleHTTPRequestHandler
import threading
import webbrowser
import time

PORT = 8000

class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)

Handler = CORSRequestHandler

def open_browser():
time.sleep(3)
print("Opening default browser: ", webbrowser.get().name)
webbrowser.open("http://127.0.0.1:8000/")

with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
threading.Thread(target=open_browser).start()
httpd.serve_forever()

启动命令行,进入目录,执行打包软件安装:
pip install -i https://pypi.python.org/simple pyinstaller

最开始用华为云的源,没有这个包,指定了原始源,自动安装一些关联包后返回成功。

然后在目录下:
pyinstaller –onefile httpserver.py
该程序会自动打包python和相关依赖到文件中,注意,这个依赖只管python的,如果有数据或者图片,需要额外添加
打完包后,在dist目录会有一个exe文件,需要用的时候,拷贝到指定目录,双击就可以直接执行了。

昇腾A2板卡调测

Posted on 2023-08-09

待做清单:
-[ ] 调用opencv接口
-[x] 调用Python 的opencv接口
-[ ] 调用Cpp的opencv接口
-[ ] 部署pytorch服务
-[x] 本地文件能够AI处理
-[ ] 能够编写网络处理图像定位
-[ ] 能够进行图像分割
-[ ] 能够进行图像比对
-[ ] 能够进行轨迹预测和评估
-[ ] 找一个运动跟踪模型跑跑试试
-[ ] 跑real-Time-Voice-Cloning声音克隆
-[ ] 跑openAi的Whisper模型试试中文

华为平台

-[x] 在modelArts上部署服务
-[ ] 昇腾平台上跑车牌识别
-[ ] 跑一下昇腾平台的sd模型
-[ ] 跑一下昇腾的语音识别
-[ ] 做一个资源监控软件
-[x] 打通A2网卡
-[x] 打通A2硬盘

新增问题:
打通网卡的内核无法使用USB设备?

fastChat测试

Posted on 2023-07-09

创建fastChat过程:

创建conda环境
conda create -n fastchat38 python=3.8
conda activate fastchat38

安装支持cuda 的pytorch
pip3 install torch torchvision torchaudio -index-url https://download.pytorch.org/whl/cu118

连不上,改用conda安装
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

pip3 install fschat
git clone https://github.com/lm-sys/Fastchat.git

mkdir -p models/vicuna-7b-v1.3
下载模型到该目录,源
地址:https://huggingface.co/lmsys/vicuna-7b-v1.3

补充环境
pip install mess_ratio

python -m fastchat.serve.cli –model-path models/vicuna-7b-v1.3
可以通过参数切换CPU和GPU。我用CPU 志强4210和GPU4090分别测试,差异还是很明显的,GPU跑在100w左右,输出时间只有CPU的四分之一或者更短。

跑web(尚未跑通):

conda activate fastchat38
cd D:\tmp\FastChat\Fastchat

python -m fastchat.serve.controller
python -m fastchat.serve.model_worker –model-path models/vicuna-7b-v1.3

python -m fastchat.serve.test_message –model-name vicuna-7b-v1.3
python -m fastchat.serve.gradio_web_server

· 启动控制器
python3 -m fastchat.serve.controller
· 启动model worker
python3 -m fastchat.serve.model_worker –model-path /path/to/vicuna/weights
当进程完成模型的加载后,会看到「Uvicorn running on …」。
· 发送测试消息
python3 -m fastchat.serve.test_message –model-name vicuna-13b
· 启动gradio网络服务器
python3 -m fastchat.serve.gradio_web_server

在图形中展示

Posted on 2022-02-09

参考资料依旧为《人工智能原理与实践-基于python语言和tensorFlow》
使用 TensorBoard

安装方式为:在conda终端中输入:
conda install tensorboard
然后,生成图
writer = tf.summary.FileWriter('.\my_graph',sess.graph)
退出后再终端输入
tensorboard --logdir="my_graph"

tf样例1和tf样例2

Posted on 2022-02-06

首先测试了一个书上样例:

1
2
3
4
5
6
7
8
9
10
import tensorflow as tf
a = tf.constant(5,name="input_a")
b = tf.constant(3,name="input_b")
c = tf.multiply(a,b,name="mul_c")
d = tf.add(a,b,name="add_d")
e = tf.add(c,d,name="add_e")

sess = tf.Session()
sess.run(e)

报错:

1
2
3
4
  File "C:\Users\qinsi\tensorflow_workspace\steam_tf.py", line 8, in <module>
sess = tf.Session()
AttributeError: module 'tensorflow' has no attribute 'Session'

这个在昨天的样例中碰到过,是v1和v2的版本区别。
修改为
sess = tf.compat.v1.Session()
后可以跑起来,在run步骤报如下错误:
Tensor.graph is meaningless when eager execution is enabled.
先找了一个hello跑了一下,可用:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : TensorFlow入门操作.py
# @Author: 赵路仓
# @Date : 2020/3/26
# @Desc :
# @Contact : 398333404@qq.com

import tensorflow as tf
import os
os.environ["CUDA_VISIBLE_DEVICES"]="0"

tf.compat.v1.disable_eager_execution()
hello=tf.constant('---Hello,TensorFlow')
config=tf.compat.v1.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.9
sess=tf.compat.v1.Session(config=config)
print(sess.run(hello))

然后查阅资料修改文件,找到一个比较通用的方法,在前面添加如下语句:

1
2
3
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

整个程序如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : TensorFlow入门操作2.py
# @Author: qinsibo.com
# @Date : 2022/02/06
# @Desc :
# @Contact : qinsibo@sohu.com
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

a = tf.constant(5,name="input_a")
b = tf.constant(3,name="input_b")
c = tf.multiply(a,b,name="mul_c")
d = tf.add(a,b,name="add_d")
e = tf.add(c,d,name="add_e")
# 关闭动态图机制
tf.compat.v1.disable_eager_execution()
#
tf.compat.v1.get_default_graph()
sess = tf.compat.v1.Session()
hello=tf.constant('---Hello,TensorFlow')
#print(sess.run(hello))
print(sess.run(e))
sess.close()

输入结果为:

1
2
3
4
5
6
7
8
9
(TensorFlowGPU3_9) C:\Users\qinsi\tensorflow_workspace>python steam_tf.py
WARNING:tensorflow:From C:\Users\qinsi\anaconda3\envs\TensorFlowGPU3_9\lib\site-packages\tensorflow\python\compat\v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
2022-02-06 13:10:41.291245: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-02-06 13:10:41.798922: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1360 MB memory: -> device: 0, name: NVIDIA GeForce GTX 750 Ti, pci bus id: 0000:01:00.0, compute capability: 5.0
23

结果正确
手里的资料还是有点老,后续争取找一下tf2的相关资料进行进一步学习。

安装tensorFlow

Posted on 2022-02-05

步骤:
1.下载anaconda虚拟环境,默认安装
2.下载CUDA-tools,默认安装 。测试是否成功方法,打开命令行,输入nvcc -V 看到类似如下版本号等信息就是成功

1
2
3
4
5
6
7
(TensorFlowGPU3_9) C:\Users\qinsi>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Fri_Dec_17_18:28:54_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.6, V11.6.55
Build cuda_11.6.r11.6/compiler.30794723_0

3.在anaconda中选择environments 选择中间最下面的create,创建默认环境TensorFlowGPU3_9
4.点三角号启动,选择Open Terminal
5.输入pip install tensorflow-gpu
注意:如报错,可尝试先安装pip install pip-search

6.安装完成后,python执行,然后

import tensorflow as tf
hello = tf.constant(‘hello,tf’)
sess = tf.compat.v1.Session()

输出显卡信息:
2022-02-06 02:32:19.969053: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-02-06 02:32:20.583606: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1360 MB memory: -> device: 0, name: NVIDIA GeForce GTX 750 Ti, pci bus id: 0000:01:00.0, compute capability: 5.0
表示安装成功。

前一页1234下一页

39 posts
15 tags
© 2025 qinsibo
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
津ICP备19000975号-1
# 津ICP备19000975号-1